-
>Prelude, I've always been pretty confused about buffers. From
>your reply, I gather that characters only leave the buffer when
>scanf is successful, otherwise they just stay there?
Correct, if scanf fails then whatever is not read will remain in the stream.
>I've noticed that you are one of the main moderators here and
>you seem to really know your stuff. Do you do this while you're
>programming?
Well, I'm not a moderator but I do spend a lot of time here. I'm usually around during the day when I'm at work and nothing is going on ( which is often ).
-Prelude
-
Prelude, is there much demand for C programmers right now? I'm kind of looking for my first programming job. I took a hardware course that included two C classes and then learned the C portion of Deitel.
-
>is there much demand for C programmers right now?
Right now the pickings are very slim and entry level positions are all but nonexistant. This should change soon, but it's impossible to guess when.
-Prelude
-
Prelude, do you find that the board is a good way to keep your skills sharp? Or is it more of a pastime?
-
>Prelude, do you find that the board is a good way to keep your
>skills sharp? Or is it more of a pastime?
For the most part it's a passtime, but every once and a while a question pops up that requires me to double check myself or do research to find the answer. And "find the error" questions are useful for keeping my debugging skills sharp since you see some strange errors around here. ;)
-Prelude
-
Prelude, just wanted to thank you for your insights, and will be talking to you again on some other threads!
-
scanf
Hi,
Below is a way around the scanf problem. Maybe not the best but it works in both of my 16bit compilers and the free Borland 5.5.
#include<stdio.h>
#include <conio.h>
int main()
{
char errorbuff[100]; //Really doesn't have to be this large.?
int numberin;
int correctflag; // Set when a int is entered
for(correctflag = 0; correctflag == 0; )
{
printf("\nEnter A Number ");
if(!scanf("%d",&numberin)) // the entry was not an int.
{
scanf("%s",errorbuff);
}
else
{
correctflag = 1;
}
}
printf("\nNumber entered %d",numberin);
getch();
return 0;
}
Just another way.
Hope it helps.
-
>if(!scanf("%d",&numberin)) // the entry was not an int.
>{
>scanf("%s",errorbuff);
>}
>else
>{
>correctflag = 1;
>}
Eight lines just do handle a bug with scanf?
-Prelude