-
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 }
-
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.
-
Im just using the scanf because it acts kinda like system(PAUSE).
What should I do to fix #define Orange?
-
Should I put under #define ORANGE textcolor(ORANGE)??
-
-
Acl, I fixed it. I forgot to put the ';' at the end of return (0)
-
-
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?
-
>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
-
aiks ya ! prelude ?? ...
why not use this...
system ("pause");
so the printf message no need to diaplay it.
very easy and convienent, right?
-
>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
-
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
:D :D :D
-
>benefit of system ("pause");
I don't care if you use it, I prefer not to though. Both of our reasons are valid.
-Prelude
-
hey hey my friend, don't so angry. LOL sorry there. :D :D :D
-
>hey hey my friend, don't so angry.
Angry? Hehe, you obviously haven't seen me get angry. :D
-Prelude