|
-
Jun 1st, 2000, 10:10 PM
#1
Ok, im using C and i cant get this code to work...
int check;
scanf("%s", &check);
if(check == 'hi')
printf("Hello\n");
The problem is when I type "hi", it wont print "Hello".
Any idea?
-
Jun 1st, 2000, 10:50 PM
#2
Junior Member
I think you need to use double quotes around the "hi" rather than single quotes. If I remember right, single quotes are used for char variables and double quotes are used for strings. But it's been a while, so forgive me if I am wrong.
-CD
-
Jun 2nd, 2000, 12:04 AM
#3
Ok i got that to work, but what do i type to terminate the program?
-
Jun 2nd, 2000, 06:31 AM
#4
Hyperactive Member
You mean in the code itself? Return 0 from main to indicate successful termination. Otherwise return 1.
Or if you include "STDLIB.H" you can call the exit function which is: exit(status)
where status is 0 for sucess or 1 for error.
"People who think they know everything are a great annoyance to those of us who do."
-
Jun 2nd, 2000, 09:48 AM
#5
Ok thanks i got the exit thing to work. Now i got to more questions.
1. How do i clear the screen?
2. Is there a place (like a web site or something? ) to look up the functions in the header files and see what they do?
-
Jun 4th, 2000, 11:54 AM
#6
New Member
Originally posted by ChimpFace9000
Ok thanks i got the exit thing to work. Now i got to more questions.
1. How do i clear the screen?
2. Is there a place (like a web site or something? ) to look up the functions in the header files and see what they do?
1) Assuming MSVC and a console app, look up _clearscreen() in the help files (<conio.h>).
2) Do you have the help files? Failing that a web search for one of the functions will no-doubt get you a few pages with some sorta defn for them.
Shab.
Code:
Print WeekDayName(vbMonday)
-
Jun 4th, 2000, 01:17 PM
#7
Ok, i found it but couldnt get it to work. This is the header file i included <conio.h> and then i typed clearscreen() to clear the screen, but it didnt work.
-
Jun 4th, 2000, 07:39 PM
#8
New Member
Originally posted by ChimpFace9000
Ok, i found it but couldnt get it to work. This is the header file i included <conio.h> and then i typed clearscreen() to clear the screen, but it didnt work.
Hmm - my bad for not actually checking it. Having looked it up on the web, it appears there's no easy (nor standard) way of doing it.
Screen clearing (CLS) provides some tips though - you may want to have a look there.
Shab.
Code:
Print WeekDayName(vbMonday)
-
Jun 5th, 2000, 05:11 AM
#9
Addicted Member
if your using the Turbo C buy borland than to clear the screen all you have to do is, but not allways, include the <conio.h> and simply call the function clrscr();
Jeremy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|