cs50 / help50-deprecated

This is help50, a command-line tool that helps students understand error messages.
https://cs50.harvard.edu/
GNU General Public License v3.0
62 stars 64 forks source link

format specifies type 'int' but the argument has type '<dependent type>' #256

Closed dmalan closed 5 years ago

dmalan commented 7 years ago
$ cat test.c
#include<stdio.h>
#include<cs50.h>
#include<string.h>
int main (void)
{ string s = get_string();
 if (s != NULL);
 {

 for (int i= 0; i <strlen(s); i++);
 {

 printf ("%c\n", s[i]) ;

 }
 }
}

$ make test
clang -fsanitize=integer -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow    test.c  -lcrypt -lcs50 -lm -o test
test.c:12:18: error: format specifies type 'int' but the argument has type '<dependent type>' [-Werror,-Wformat]
 printf ("%c\n", s[i]) ;
          ~~     ^~~~
test.c:12:20: error: use of undeclared identifier 'i'
 printf ("%c\n", s[i]) ;
                   ^
test.c:9:35: error: for loop has empty body [-Werror,-Wempty-body]
 for (int i= 0; i <strlen(s); i++);
                                  ^
test.c:9:35: note: put the semicolon on a separate line to silence this warning
3 errors generated.
make: *** [test] Error 1