L
lynx_ace
Hi everyone. I need a little bit help here...I have an assignment and
it is working fine until the last part which I can't solve. So here's
the code in simple form
#define maxlength 200
while( fgets( command, MAXLLENGTH, stdin ) != NULL )
{
if( sscanf( command, "%c %d%c%d", &c, &d ,e, &f)) {
switch( c ) {
case h = print the synopsis of all emails.
*if an integer is entered after h, then print the synopsis of
that message only
example h1 will print the synopsis of message 1 only
* if the input is h1-5 then it will print the synopsis
message 1 until 5
case p = print the real message (with the content ), and also
the case number such in 'h' is just the same
and so on which i have done perfectly (I guess so )....
the problem here is...
there should be a command 's', which will search a string entered in
the whole emails and printed the messages containing the string. That
means...after the command 's', we should put a string...
example: s true means it will search the string 'true' inside the inbox
and print all of them (if the subject contains true, or the contents
has a word 'true' )
However according to the sscanf provided above, I should put an integer
after the first command character. This is where I'm stuck at... and
yeah...I'm just learning C and the information about sscanf is too
little and rare in the internet. So I really appreciate if anyone can
give me a clue how to solve this problem. ^o^
it is working fine until the last part which I can't solve. So here's
the code in simple form
#define maxlength 200
while( fgets( command, MAXLLENGTH, stdin ) != NULL )
{
if( sscanf( command, "%c %d%c%d", &c, &d ,e, &f)) {
switch( c ) {
case h = print the synopsis of all emails.
*if an integer is entered after h, then print the synopsis of
that message only
example h1 will print the synopsis of message 1 only
* if the input is h1-5 then it will print the synopsis
message 1 until 5
case p = print the real message (with the content ), and also
the case number such in 'h' is just the same
and so on which i have done perfectly (I guess so )....
the problem here is...
there should be a command 's', which will search a string entered in
the whole emails and printed the messages containing the string. That
means...after the command 's', we should put a string...
example: s true means it will search the string 'true' inside the inbox
and print all of them (if the subject contains true, or the contents
has a word 'true' )
However according to the sscanf provided above, I should put an integer
after the first command character. This is where I'm stuck at... and
yeah...I'm just learning C and the information about sscanf is too
little and rare in the internet. So I really appreciate if anyone can
give me a clue how to solve this problem. ^o^