How to ask for unspecified input in scanf?

Viewed 48

I am completely new to C and don't quite understand how the scanf function works. What I want it to do, is to take one string as the first input ('rgb'), and three more integers ('r, g, b'). This is the code:

    if(scanf(" %s ( %d , %d , %d )", rgb, &r, &g, &b) == 1){
    printf("Wrong input.\n");
    return 1;
};

If the user writes 'rgb ( 255 , 255 , 255 )' it works just fine. However, if they do not type spaces, it will not work. I want it to work in both cases, with or without spaces and definitely with commas and brackets.

Thanks in advance

0 Answers
Related