View Full Version : Help With Simple C Program

08-31-2011, 12:37 AM
I'm getting errors and its not compiling can someone please let me know what is wrong with my code. I'm trying to have the name you enter appear on the screen 100 times.

Heres my code

#include <iostream>
#include <stdio.h>

int main(){
int x;
char name[20];

printf("Please Enter Your Name:");
for (x=0;x<100;x++){
scanf("%s", &name);
printf("Your Name is %s", name);
system ("pause");


And heres an image with the errors

and if I do what the error says add StdAfx.h I just get another error saying it cant open source file StdAfx.h

08-31-2011, 07:19 AM
Did you use quotes when including StdAfx.h? If you use the <> instead of quotes, that would be why it complained it couldn't find it.

Another solution is to simply not use precompiled headers. You can turn it off in the project settings. That is probably going to be easier for you if you are a beginner.

09-01-2011, 12:35 AM
precompiled headers are sometimes a pain in the ... getting rid of them would fix the situation. Good Luck. :thumbsup: