For the following program, xcode compiles and runs the program fine but gives the aforementioned error. Why is it bad to use gets()?
Here is the program for which xcode gave the error:
Converting lowercase string to uppercase:
Here is the program for which xcode gave the error:
Converting lowercase string to uppercase:
Code:
#include <stdio.h>
int main(int argc, const char * argv[])
{
// insert code here...
char str[100], i;
printf("Enter a string");
gets(str);
for(i=0;i<100 ; )
{
if((str[i]>=97)&&(str[i]<=123))
str[i]-=32;
i++;
}
printf("%s", str);
return 0;
}
Last edited by a moderator: