preprocessor!!

This is a discussion on preprocessor!! within the C++ Programming forums, part of the General Programming Boards category; i was typing a simple code in my c ide,i got stuck through a problem, plz help me out!! Code: ...

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    12

    preprocessor!!

    i was typing a simple code in my c ide,i got stuck through a problem, plz help me out!!






    Code:
    #inlcude <stdio.h>
    main()
    {
    
    for (x=1; x<10; x++);
    	 printf("%d\n",x);
     }

    i got the rror message, Compiling NONAME02.CPP:
    Error NONAME02.CPP 1: Unknown preprocessor directive: 'inlcude'
    Error NONAME02.CPP 5: Undefined symbol 'x' in function main()
    Error NONAME02.CPP 6: Call to undefined function 'printf' in function main()
    Warning NONAME02.CPP 7: Function should return a value in function main()

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,781
    It is just a typo error. "#inlcude <stdio.h>" should be "#include <stdio.h>", or "#inlcude <cstdio>".

    Of course, other potential problems include:
    1. a missing return type for main (should be int)
    2. x is used without being declared
    3. the for loop has a semi-colon that makes the loop do nothing.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    you probably also want to remove the last semicolon on the for() loop line
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  4. #4
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    Quote Originally Posted by laserlight
    It is just a typo error. "#inlcude <stdio.h>" should be "#include <stdio.h>", or "#inlcude <cstdio>".
    Or "#include <cstdio>"

  5. #5
    Registered User
    Join Date
    Feb 2006
    Posts
    312
    Quote Originally Posted by Frobozz View Post
    Or "#include <cstdio>"
    it seems that teh typo disease has gotten laserlihgt too.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,781
    It is called copy and paste error, not typo error
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    just to summarize things said above, here is the (hopefully) correct code:

    Code:
    #include <cstdio>
    int main()
    {
    for (int x=1; x<10; x++)
    	 printf("%d\n",x);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C/C++ preprocessor directives
    By coletek in forum C++ Programming
    Replies: 11
    Last Post: 01-11-2009, 03:24 PM
  2. Writing an HTML Preprocessor
    By thetinman in forum C++ Programming
    Replies: 1
    Last Post: 09-17-2007, 08:01 AM
  3. Preprocessor Directives Problem
    By MipZhaP in forum C++ Programming
    Replies: 6
    Last Post: 02-18-2005, 12:53 PM
  4. Preprocessor string pasting fun
    By ggambett in forum C Programming
    Replies: 6
    Last Post: 11-11-2004, 05:40 PM
  5. Preprocessor Functions
    By mart_man00 in forum C Programming
    Replies: 2
    Last Post: 01-09-2003, 08:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21