Thread: why am I getting these errors?

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    35

    why am I getting these errors?

    Code:
    /*********************************************************/
    Program Name:program1
    Author:geekrockergal
    
    
    /***************PREPROCESSOR DIRECTIVES********************/
    
    /********************HEADER FILES**************************/
    #include <CONIO.H> /*Console I/O Header*/
    #include <STDIO.H> /*StandardI/O Header*/
    /******************NAMED CONSTANTS*************************/
    
    /*****USER-DEFINED AND ENUMERATED DATA TYPES***************/
    
    /*****************FUNCTION PROTOTYPES**********************/
    
    /***********************GLOBAL VARIABLES*******************/
    
    /*******************MAIN FUNCTION**************************/
    
    void main (void)
    {
        printf("Please input letter: ");
        int %c
        printf("The letter you have inputted is: "%c);
    }
    /***********************OTHER FUNCTIONS********************/
    why am I getting these errors?
    Error PROGRAM1.C 2: Declaration syntax error (aka the semi colon after Name)
    Error PROGRAM1.C 6: Unable to open include files 'CONIO.H'
    Error PROGRAM1.C 7: Unable to open include files 'STDIO.H'

    thanks

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Code:
    /*********************************************************/
    // Illegal: not valid C. Must be enclosed in comments.
    Program Name:program1
    Author:geekrockergal
    
    
    /***************PREPROCESSOR DIRECTIVES********************/
    
    /********************HEADER FILES**************************/
    #include <CONIO.H> /*Console I/O Header*/
    #include <STDIO.H> /*StandardI/O Header*/
    /******************NAMED CONSTANTS*************************/
    
    /*****USER-DEFINED AND ENUMERATED DATA TYPES***************/
    
    /*****************FUNCTION PROTOTYPES**********************/
    
    /***********************GLOBAL VARIABLES*******************/
    
    /*******************MAIN FUNCTION**************************/
    
    // No such thing as void main. There is only int main.
    void main (void)
    {
        printf("Please input letter: ");
        int %c // %c is not a valid variable name. Missing ;
         // %c is not a variable or name, and variables must be passed as additional arguments (ie a , before them).
        printf("The letter you have inputted is: "%c);
    }
    /***********************OTHER FUNCTIONS********************/
    And as for the include errors... perhaps you are not compiling right - the compiler cannot find the required headers or if you use an IDE, it's incorrectly configured. Hard to say.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    35
    Quote Originally Posted by Elysia View Post
    Code:
    /*********************************************************/
    // Illegal: not valid C. Must be enclosed in comments.
    Program Name:program1
    Author:geekrockergal
    
    
    /***************PREPROCESSOR DIRECTIVES********************/
    
    /********************HEADER FILES**************************/
    #include <CONIO.H> /*Console I/O Header*/
    #include <STDIO.H> /*StandardI/O Header*/
    /******************NAMED CONSTANTS*************************/
    
    /*****USER-DEFINED AND ENUMERATED DATA TYPES***************/
    
    /*****************FUNCTION PROTOTYPES**********************/
    
    /***********************GLOBAL VARIABLES*******************/
    
    /*******************MAIN FUNCTION**************************/
    
    // No such thing as void main. There is only int main.
    void main (void)
    {
        printf("Please input letter: ");
        int %c // %c is not a valid variable name. Missing ;
         // %c is not a variable or name, and variables must be passed as additional arguments (ie a , before them).
        printf("The letter you have inputted is: "%c);
    }
    /***********************OTHER FUNCTIONS********************/
    And as for the include errors... perhaps you are not compiling right - the compiler cannot find the required headers or if you use an IDE, it's incorrectly configured. Hard to say.
    thanks Im using borland by the way
    Im new to C so I make a lot of beginners mistakes !!!
    Thanks to everyone for helping, Im must be really annoying you *bangs head on desk*

  4. #4
    Registered User ralu.'s Avatar
    Join Date
    Feb 2009
    Location
    Bucharest, RO
    Posts
    32
    Quote Originally Posted by geekrockergal View Post
    Code:
    /*********************************************************/
    Program Name:program1
    Author:geekrockergal
    
    
    /***************PREPROCESSOR DIRECTIVES********************/
    
    /********************HEADER FILES**************************/
    #include <CONIO.H> /*Console I/O Header*/
    #include <STDIO.H> /*StandardI/O Header*/
    /******************NAMED CONSTANTS*************************/
    
    /*****USER-DEFINED AND ENUMERATED DATA TYPES***************/
    
    /*****************FUNCTION PROTOTYPES**********************/
    
    /***********************GLOBAL VARIABLES*******************/
    
    /*******************MAIN FUNCTION**************************/
    
    void main (void)
    {
        printf("Please input letter: ");
        int %c
        printf("The letter you have inputted is: "%c);
    }
    /***********************OTHER FUNCTIONS********************/
    why am I getting these errors?
    Error PROGRAM1.C 2: Declaration syntax error (aka the semi colon after Name)
    Error PROGRAM1.C 6: Unable to open include files 'CONIO.H'
    Error PROGRAM1.C 7: Unable to open include files 'STDIO.H'

    thanks
    The error is because this:

    Program Namerogram1
    Author:geekrockergal

    This sould be a comment so make it a comment:
    /*
    Program Namerogram1
    Author:geekrockergal
    */

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Internet forums and newsgroups are not always easy on your feelings. Try to ignore most deprecating comments you encounter. That will let you concentrate on the reason you came to the forum in the first place, and use the forum for what it was intended for - programming information.

    Did you get that bit about the % sign? It should not be a part of any variable. It's a special character in C that tells the compiler "I've got a variable coming up right after me (and maybe some modifiers for that variable, also)".

    So
    Code:
    scanf("%c", &var);  //enter the var variable it's a character - just one, and this is it's address.
    scanf("%d", &age); //enter the integer variable named age, and this is it's address.
    scanf("%s", name) //the name variable is a char array - name[], and "name" is the address.
    
    printf("%c", var);  //print the char variable named var.
    printf("%3d, age);  //print the integer variable named age, inside a field that is 3 char's wide.
    printf("%s, name); //print the string variable named name.
    There are other data types, of course, and they will all use the % in front of them, for scanf(), fscanf(), printf(), fprintf(), and related functions, in C.

  6. #6
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    i think what u're going wrong is that STDIO.H & CONIO.H are not the headers in c.the proper headers are stdio.h & conio.h as c is case sensitive.

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I'm not sure that might be a problem. Some operating systems like Windows is not case-sensitive, so telling it to include STDIO.H or stdio.h won't matter.
    But I do agree that it might be better to keep them lower case.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Registered User ralu.'s Avatar
    Join Date
    Feb 2009
    Location
    Bucharest, RO
    Posts
    32
    Quote Originally Posted by BEN10 View Post
    i think what u're going wrong is that STDIO.H & CONIO.H are not the headers in c.the proper headers are stdio.h & conio.h as c is case sensitive.
    It's true that c is case sensitive but for the name of the header file it doesn't matter if u write it with lower/upper letters.
    I have stopped reading Stephen King novels. Now I just read C code instead.

  9. #9
    Registered User
    Join Date
    Jan 2009
    Posts
    35
    Quote Originally Posted by ralu. View Post
    The error is because this:

    Program Namerogram1
    Author:geekrockergal

    This sould be a comment so make it a comment:
    /*
    Program Namerogram1
    Author:geekrockergal
    */
    thanks
    Last edited by geekrockergal; 02-07-2009 at 07:31 AM.
    Im new to C so I make a lot of beginners mistakes !!!
    Thanks to everyone for helping, Im must be really annoying you *bangs head on desk*

  10. #10
    Registered User
    Join Date
    Jan 2009
    Posts
    35
    Quote Originally Posted by BEN10 View Post
    i think what u're going wrong is that STDIO.H & CONIO.H are not the headers in c.the proper headers are stdio.h & conio.h as c is case sensitive.
    Ive tried it in both upper and lower case and I still get the same error
    Im new to C so I make a lot of beginners mistakes !!!
    Thanks to everyone for helping, Im must be really annoying you *bangs head on desk*

  11. #11
    Registered User
    Join Date
    Jan 2009
    Posts
    35
    Quote Originally Posted by Adak View Post
    Internet forums and newsgroups are not always easy on your feelings. Try to ignore most deprecating comments you encounter. That will let you concentrate on the reason you came to the forum in the first place, and use the forum for what it was intended for - programming information.

    Did you get that bit about the % sign? It should not be a part of any variable. It's a special character in C that tells the compiler "I've got a variable coming up right after me (and maybe some modifiers for that variable, also)".

    So
    Code:
    scanf("%c", &var);  //enter the var variable it's a character - just one, and this is it's address.
    scanf("%d", &age); //enter the integer variable named age, and this is it's address.
    scanf("%s", name) //the name variable is a char array - name[], and "name" is the address.
    
    printf("%c", var);  //print the char variable named var.
    printf("%3d, age);  //print the integer variable named age, inside a field that is 3 char's wide.
    printf("%s, name); //print the string variable named name.
    There are other data types, of course, and they will all use the % in front of them, for scanf(), fscanf(), printf(), fprintf(), and related functions, in C.
    yes I did understand the bit about % thank you
    Im new to C so I make a lot of beginners mistakes !!!
    Thanks to everyone for helping, Im must be really annoying you *bangs head on desk*

  12. #12
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I suggest you use fgets when reading strings, however.
    fgets(name, sizeof(name), stdin);
    For a full explanation (this might be above your level, which is why I suggested the above), you can read this: http://apps.sourceforge.net/mediawik...tle=Scanf_woes
    It explains why it's bad to read strings with scanf and how to fix it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #13
    Registered User
    Join Date
    Jan 2009
    Posts
    35
    Quote Originally Posted by Elysia View Post
    I suggest you use fgets when reading strings, however.
    fgets(name, sizeof(name), stdin);
    For a full explanation (this might be above your level, which is why I suggested the above), you can read this: http://apps.sourceforge.net/mediawik...tle=Scanf_woes
    It explains why it's bad to read strings with scanf and how to fix it.
    okay try and find a way around not using strings
    Im new to C so I make a lot of beginners mistakes !!!
    Thanks to everyone for helping, Im must be really annoying you *bangs head on desk*

  14. #14
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by ralu. View Post
    It's true that c is case sensitive but for the name of the header file it doesn't matter if u write it with lower/upper letters.
    as was said before - it depends on operating system
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  2. Winsock compilation errors
    By jmd15 in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-03-2005, 08:00 AM
  3. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  4. Help me with these errors... :-(
    By major_small in forum C++ Programming
    Replies: 6
    Last Post: 09-07-2003, 08:18 PM
  5. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 06:51 PM