C: How to filter commands? -


i asked write program operates on given string. commands come in form of 2 letters followed nothing, or int(s) or string(s). commands work on given string (reversing it, multiplying it, replacing instances of substring substring).

i'm pretty new c , programming in general, , have difficulty in recieving commands themselves. how both make sure command i'm given correct in both name , arguments? need use array of functions (does exist?) after i've found command given correct?

i'd recommend learn how use sscanf, sounds perfect want.

if string stored in array a, can use see if 2 letters "ia" followed int:

sscanf(a, "ia %d", &intvar); 

if want check case of letters "sa" followed string:

sscanf(a, "sa %s", &chararray); 

the key here checking return value of sscanf, can know how many of arguments assigned values format string. means can add arguments more strings, assuming there's maximum number of ints / strings follow 2 letters.


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -