How do I have an infinite loop. The while should exit when it reaches the null character. Setting the count to however many times it counted up to the null character.
Code:
#include <stdio.h>
4 #include <stdlib.h>
5
6 int stringlength( char s, 50);
7 int count = 0;
8
9 int main (void)
10
11 {
12
13 char s [ 50 ];
14 int length;
15
16 printf("Please enter a string\n");
17 scanf("%s", s);
18
19 length = stringlength(count);
20
21 printf("The length of the string is %d\n",length);
22
23 return 0;
24
25 }
26
27 int stringlength( char s, 50 )
28
29 {
30
31
32 while ( s != NULL ) {
count++;
34 }
35
36 return count;
37
38
39 }
error: expected declaration specifiers or â...â before numeric constant
.c:27: error: expected declaration specifiers or â...â before numeric constant
In function âstringlengthâ:
warning: comparison between pointer and integer