Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2010
    Posts
    269
    Thanks
    8
    Thanked 1 Time in 1 Post

    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
    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

    http://imageshack.us/f/849/picor.png/
    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; 08-31-2011 at 01:53 AM.

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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.
    OracleGuy

  • #3
    New Coder
    Join Date
    Sep 2011
    Location
    Sacramento
    Posts
    17
    Thanks
    2
    Thanked 1 Time in 1 Post
    precompiled headers are sometimes a pain in the ... getting rid of them would fix the situation. Good Luck.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •