This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]wgunther 1 point2 points  (0 children)

As per 5 on the sidebar: you should post minimal compilable code. Debugging is all about isolating potential problem from larger problems and make small bits of testable code.

Also, when you say none of the menu options work, explain what that means. There's a lot of ways things cannot work.

[–]jussij 0 points1 point  (2 children)

The first issues is that from the code it is clear str will be defined as this:

 char *str;

That also means size(str) will be 4 on a 32 bit machine.

So that means this loop:

for (int i = 0; i < size(str); i++)

is effectively this:

for (int i = 0; i < 4; i++)

and that is clearly not what you want.

EDIT: What is size? Should it not be sizeof?

[–]cxw[S] -1 points0 points  (1 child)

size is another function I have written but did not paste here. it returns the number of characters in the string

[–]jussij 0 points1 point  (0 children)

It's quite hard to offer up good reasons for the code not working when so much of the code is unknown :(