When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
13 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
strlen(x)
ahh ok sick is that in the std library?
its in string.h, which comes standard ^^
Ahh ok that makes sense. So would I initialize the input variable as a character or a string ?
btw how are you getting the input?
you must always set a limit on the input function itself, that's why gets is deprecated, it got no such feature.
char buff[2]; // example: {'a', '\n'}
scanf("%s", buff);
int i = buff[1] == '\0';
//if i == 0, string is 1 character, if not, its to long
//safety measures (beause scanf does not nullterminate a buffer if the input is too long):
buff[1] = '\0'
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity