Reputation: 3
Hello i'm beginner in C programming. I'm making program that should crawls though elements of a string, the string is input from the user. The problem is that I need the size of the characters in the string I have try a lot of thing none of them worked.
for(int i = 0; i <= cUserInput; i++){
if(&cUserInput[i] == cFirstLineR[i]){
printf("Check///Failed\n");
}
cUserInput
is the user input. I need its size.
cFirstLineR
is an array of characters to camper with.
Upvotes: 0
Views: 492
Reputation: 105
Use the function strlen(const char* str)
to get a strings' size. It will count the characters until the NUL
terminator. See reference here:http://www.cplusplus.com/reference/cstring/strlen/
NOTE: to use it you have to include the header "string.h"
Upvotes: 1
Reputation: 1309
There is a function called sizeof ()
that should work with your problem...
Upvotes: 0