![]() |
|
#1
|
|||
|
|||
a C input question..Hi, guys...I have a question about keyboard input in C
let's say I have a program which allows user to type in command commands are in the form: command parameter1 parameter2...etc since commands have different # of parameters..I'll need to use fgets or gets to get the whole command string and parse it... also, I'll allow user to continue inputing command except when they type in "quit" this is how I do it.. CPP / C++ / C Code:
but here comes a problem... if a user didn't type anything, but just hit ENTER....it'll have a segmentation fault, becuz the fgets will have some problem with nothing entered....I thought that the fgets will return NULL..so I can use that condition to detect this kind of situation and just loop around again.....but it doesn't happen that way... I was wondering if there's a way I can do to make my program keeps waiting for user command, even if the user decided to press a whole lot of ENTERs, it'll just loop around.. tks.... |
|||
|
#2
|
|||
|
|||
|
ha....I figured it out...
sorry about the post..... |
|
#3
|
|||
|
|||
|
No worries! You wanna say how you fixed it?
GF |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| a C input question | tmike | C Programming Language | 1 | 16-Sep-2003 03:31 |
| a noobish compiler question | Charunks | C++ Forum | 5 | 03-Sep-2003 03:18 |
| Script needed for letting user input a few days of data for tracking and analysis. | tradertt | MySQL / PHP Forum | 3 | 06-Mar-2003 03:54 |
| 'Related articles' php /mysql question | JdS | MySQL / PHP Forum | 4 | 06-Sep-2002 11:17 |
| PHP Sessions question | JdS | MySQL / PHP Forum | 2 | 16-Jul-2002 05:58 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The