This doesn't compile for me as string is not defined.
before the main, use typedef char* string, or replace string with char* everywhere.
Second, you are using argc in your counter... why is that? You aren't using argv anywhere, even if you were, would it really tell you the size of cypherText?
I think the problem though is in the way that printf is driven (this is where my breakpoint was triggered during the crash). I'm not really that used to printf as I use c++'s iostream instead so I can't give you too much info, but this is what I would do:
This doesn't compile, as string is referenced but the header <string> is not included.
The declaration of main() is wrong. argc is a count of how many command-line parameters were received (the first is always the name of the program itself).
Thanks for responding...
string is defined in <cs50>. I am a hobbiest programmer in c# and java, but I decided to try to teach myself c (c99) and c++ for better understanding. I know obviously this is a c++ forum so I apologize that my question is about c99.
but my main problem is :
I've been using printf for debug because i'm not using an IDE so I have to learn "how it works"
I seem to get the error when I call the function:
Yet again you have used an incorrect declaration for main() int main(int argc, string argv[])
It should be like this: int main(int argc, char * argv[])
To find the length of a c++ string, you can do one of the following: cypherText.size() or cypherText.length();
the strlen() function is for c-strings only.
Most of the problems here are the result of mixing newer C++ strings with old C functions like printf().
I just realised I may have overlooked something. I'm thinking in (mostly) C++ terms. But if we use #define string char * then maybe the program could work virtually unchanged.