Urgent help in finding the length
Hello all,
I need help with finding the length of the string input by the user.
It prints out 100 each time.
Also i cannot use the strlen function
Also is there a way that each of those strings can be converted to single characters? like each of s can be assigned to a char?
Thank You for ur help...
Code:
#include <stdio.h>
#define MAX 100
int main( int argc, char *argv[]) {
char s[MAX];
int i, j=0;
// char c;
printf("Enter a string\n");
fgets(s, MAX, stdin);
for(i =0; i<MAX; i++ ) {
s[MAX] = j;
j++;
}
printf("The repetition of this line is:");
puts(s);
printf("The length is %d.\n", j);
return 0;
}