Web Analytics Made Easy -
StatCounter Help With Simple C Program - CodingForum


No announcement yet.

Help With Simple C Program

  • Filter
  • Time
  • Show
Clear All
new posts

  • Help With Simple C Program

    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
    Last edited by andynov123; Aug 30, 2011, 09:53 PM.

  • #2
    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.


    • #3
      precompiled headers are sometimes a pain in the ... getting rid of them would fix the situation. Good Luck.
      Looking for web designer for these projects: free samples, free dating sites, payday loans online pm me if interested...