Author Topic: while loop segmentation fault  (Read 2468 times)

multiabhay

  • Guest
while loop segmentation fault
« on: December 26, 2014, 06:14:28 am »
Hi guys!
I am haivng a little problem in code::blocks
here is the code:

#include <iostream>
#include <string>

using namespace std;

int main()
{

    string list[] = {"one", "two", "three"};



    int index = 0;
    while(index < 4)
    {
        cout << list[index];
        index ++;
    }



   

    return 0;
}


Getting Error : Segmentation Fault .


I am using Linux mint 17.1


Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: while loop segmentation fault
« Reply #1 on: December 26, 2014, 07:01:14 am »
This question is a general programing question, so it violates our forum rule. So, I suggest try ask in a suitable forum to seek help.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: while loop segmentation fault
« Reply #2 on: December 26, 2014, 11:42:39 am »
This question is a general programing question, so it violates our forum rule. So, I suggest try ask in a suitable forum to seek help.
Topic locked therefore.
And please use code-tags (#) if you paste code in the forum.
Thank you!