I am building a program that should find a char in a string according to lower case alphabet.
#include <stdio.h>
#include <string.h>
int main()
{
char str[];
int i;
for (i = 0; i < strlen(str); i++)
{
if (str[i] < 48 || str[i] > 57)
break;
}
return 0;
}
I've never had this problem before and I used incomplete types (arrays and strings) hundered situations.
Anyway, Visual Studio 2012 alerts about incomplete type:
1 IntelliSense: incomplete type is not allowed Visual Studio 2012\Projects\C\C\main.c 6 7 C
What is wrong?
char str[]as a parameter is not an incomplete type; it is equivalent tochar* strin that context. (If you were to replacechar str[]withchar* strabove, that would be undefined behavior and the program would probably crash.) Andchar str[] = "abc";is also not an incomplete type -- the array size (4) is determined from the initializer.if (str[i] < 48 || str[i] > 57)this sort of thing is useful for entries in "Obfuscated C" contests but is awful practice otherwise.