Hi there, is it possible leave a scanf blank? For example my code is:


After entering the string for "a", I would like to leave "b" blank so I press enter but it just jumps over to the next line, is there a way to leave a "b" blank?

I tried using this:


And it works when I want to press enter, but whenever I input a "b" string, it would come out as " string". For example I input in "ls /root", string "b" would be registered as " /root", as you can see there is a whitespace before /root, therefore problem still exists.

Any help would be appreciated, thanks :D

Seems like its my lucky day today, been doing this for a lot of hours and I figured out how to do it! :D

using a remove spaces function!!

void RemoveSpaces(char* b)
  char* i = b;
  char* j = b;
  while(*j != 0)
    *i = *j++;
    if(*i != ' ')
  *i = 0;


phew, I'm tired now. haha

This question has already been answered. Start a new discussion instead.