Well, as nice as command != ('A' || 'B') looks it doesn't work like that. if( command != 'A' || command != 'B' ) is what you're looking for, but to be honest a straight out else should do -- it's proven to neither be an 'A' or 'B'.
Not sure if that's your problem now. Don't have linux.
twomers
Posting Virtuoso
1,877 posts since May 2007
Reputation Points: 453
Solved Threads: 57
My program works properly under windows, however, it seg faults when I try to compile/run it under linux.
So, how did you get the executable program when there were compile erorrs? No respectable compiler produces the executable under that condition. Do you not look at the messages your compiler produces?But, like I said, it does work under Windows, just not Linux.
The exact same code ? Is yes, then its impossible you could have gotten a clean compile.
Ancient Dragon
Retired & Loving It
30,042 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
No it doesn't make sence. What compiler are you using ? No compiler in the world would have given you a clean compile with those errors in it. You just did not pay any attention to the errors your compiler gave you.
Ancient Dragon
Retired & Loving It
30,042 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
> My program works properly under windows, however, it seg faults when
> I try to compile/run it under linux.
Unfortunately, that just makes you lucky, not good.
Code sometimes works, despite your best attempts to muck it up. Yet at other times, even the most minor transgression is severely punished.
> strcpy(location, (location + strlen(fileline)));
Overlapping copies using strcpy() are undefined (meaning anything can happen - like working vs. seg fault).
Try copying via a second array.
Why are you using messy C char arrays in a C++ program by the way?
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
Yes, I realize using char arrays is terrible, but those were assignment requirements.
Thanks to everyone who replied, but I've got it working now.
What did you do to resolve the problem?
superjacent
Junior Poster in Training
66 posts since Nov 2007
Reputation Points: 11
Solved Threads: 3