Thread: Help Please!

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    10

    Post Help Please!

    Ok, please don't laugh at me as I'm a total beginner. I'm just testing out the color functions in Conio.h and I made a tiny program but it doesnt work! Please help me fix these. Here is the code:
    Code:
    #include <conio.h>
    #include <stdio.h>
    #define ORANGE
    main()
    {
        textcolor (ORANGE);
        printf (" This is the color orange!/n");
        cprintf ("Orange, Orange, Orange!/n/n");
        printf ("Do you like orange??");
        scanf ("ScanF");
        return (0)
    }
    There errors I get are: 6,23:Too few parameters in call to 'textcolor'

    17,2:Return statement missing ;

    17,1:Compound statement missing }
    The Jripe.
    Whatever that means.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You're not defining ORANGE as anything.

    #define SOMETHING

    Just makes the tag SOMETHING apparent to the compiler. #define ends up defining something, and what happens is that it (the preprocessor) does a "search and replace" with whatever that word is to whatever you have defined it as.

    So what happens is that you haven't given ORANGE any value or representation, so it just goes through and snips out the word ORANGE, not replacing it with anything.

    Second, your scanf call is wrong.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    10
    Im just using the scanf because it acts kinda like system(PAUSE).
    What should I do to fix #define Orange?
    The Jripe.
    Whatever that means.

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    10
    Should I put under #define ORANGE textcolor(ORANGE)??
    The Jripe.
    Whatever that means.

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    10
    What does the '4' do?
    The Jripe.
    Whatever that means.

  6. #6
    Registered User
    Join Date
    Nov 2002
    Posts
    10
    Acl, I fixed it. I forgot to put the ';' at the end of return (0)
    The Jripe.
    Whatever that means.

  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    10
    Thanks everyone.
    The Jripe.
    Whatever that means.

  8. #8
    Registered User
    Join Date
    Nov 2002
    Posts
    10
    One more question: I've seen in C++ how to make a typing effect but I haven't seen it in C. Does anyone know how to make make it?
    The Jripe.
    Whatever that means.

  9. #9
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I've seen in C++ how to make a typing effect but I haven't seen it in C. Does anyone know how to make make it?
    Something like this?
    Code:
    #include <stdio.h>
    #include <time.h>
    
    static void sleep ( int milli )
    {
      clock_t end = clock() + milli;
    
      while ( clock() < end )
        ;
    }
    
    int main ( void )
    {
      char *msg = "This is a test";
      char *it = msg;
    
      while ( *it != '\0' ) {
        putchar ( *it++ );
    
        sleep ( 200 );
      }
    
      printf ( "\nPress return to continue" );
    
      getchar(); // Pause
    
      return 0;
    }
    -Prelude
    My best code is written with the delete key.

  10. #10
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    aiks ya ! prelude ?? ...

    why not use this...
    system ("pause");

    so the printf message no need to diaplay it.
    very easy and convienent, right?

  11. #11
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >very easy and convienent, right?
    Too easy, system should be avoided when possible. Even for someone who doesn't usually worry about performance (me), I consider the system function dreadfully slow.

    -Prelude
    My best code is written with the delete key.

  12. #12
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    benefit of system ("pause");
    1 - no need to give a message on program, eg : press any key to continue.
    2 - short code, no need printf again.
    3 - use in stdlib.h



  13. #13
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >benefit of system ("pause");
    I don't care if you use it, I prefer not to though. Both of our reasons are valid.

    -Prelude
    My best code is written with the delete key.

  14. #14
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    hey hey my friend, don't so angry. LOL sorry there.

  15. #15
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >hey hey my friend, don't so angry.
    Angry? Hehe, you obviously haven't seen me get angry.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed