void test_variants(int *i, const char *s, ...) { FILE *f = 0; char buf[100]; fscanf(f, "%ld", i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}} sscanf(buf, "%ld", i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}} my_scanf("%ld", i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}} va_list ap; va_start(ap, s); vscanf("%[abc", ap); // expected-warning{{no closing ']' for '%[' in scanf format string}} vfscanf(f, "%[abc", ap); // expected-warning{{no closing ']' for '%[' in scanf format string}} vsscanf(buf, "%[abc", ap); // expected-warning{{no closing ']' for '%[' in scanf format string}} }
i++; } return i; error: return 0; } int main(int argc, char *argv[]) { Person you = {.age = 0 }; int i = 0; printf("What's your First Name?"); int rc = my_scanf(MAX_DATA, you.first_name); check(rc > 0, "Failed to read first name."); printf("What's your Last Name?"); rc = my_scanf(MAX_DATA, you.last_name); check(rc > 0, "Failed to read last name."); printf("How old are you"); char temp[MAX_DATA]; rc = my_scanf(MAX_DATA, temp); check(rc > 0 , "Failed to read age."); you.age = atoi(temp); memset(temp, 0, MAX_DATA - 1); check(you.age > 0, "You have to enter a number."); for (i = 0; i <= OTHER_EYES; i++) {