Ahhh Segmentation error >.<


Recommended Posts

Liger

Hi guyzz,

I keep geting this segmentation error in this and i cant figure out why....can someone fix it for me? plz :cry:

thanks a million :)

Link to post
Share on other sites
Deryck

I presume it is best to ask this question (or move) to the programming section of the forum.

Link to post
Share on other sites
Zxian

Well.. I don't know how you're compiling it. I copied the whole lot to VC++ and got the following errors:

--------------------Configuration: Test2 - Win32 Debug--------------------
Compiling...
blah.cpp
e:\blah\test2\blah.cpp(43) : error C2660: 'print_valid' : function does not take 2 parameters
e:\blah\test2\blah.cpp(46) : error C2660: 'print_invalid' : function does not take 1 parameters
Error executing cl.exe.

Test2.exe - 2 error(s), 0 warning(s)

You've defined the functions as follows:

void print_valid();
void print_invalid();

When you implement them:

void print_valid(char expr[LENGTH]){ printf("VALID:  %s",expr); }

void print_invalid(char expr[LENGTH]){ printf("INVALID:  %s",expr); }

So which is it?

There are a number of other problems with your code... like for example, you don't initialize i to anything. My guess is that the program is grabbing some random number (whatever was in memory) and using that as i. When you try to access expr[-3032845] you will get a segmentation fault.

Link to post
Share on other sites
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.