Reputation: 2088
Is there a way for the user to enter nothing as input(for character array) in C? I tried the following:
'\n'
character as delimiter: scanf("%[^\n]s",str);
it gave me junk.One argument expected
)null
by alt+space
. Did not work either.Please suggest me a new way or correct me if I am doing any of the above steps wrong. Note: I am using Windows.
Upvotes: 1
Views: 348
Reputation: 144550
If you take your input from command line arguments, you can specify an empty string with:
C:\>myprogram ""
argc
will be 2
and argv[1]
will be a pointer to an empty string.
Upvotes: 3