Iam currently working on pset1 mario .when i used
printf(" "); to print spaces before hash it didn't work as expected.but then i used
printf("%s"," ") it works now .what is the reason behind this?
They should work exactly the same.
printf(" "); will print a single space, the content between the double quotes.
printf("%s"," ") will grab the first parameter
" "after the format string,
"%s" and substitute it in for the placeholder %s. While the mechanism is a little different, it has the same result of printing a single space.
I am suspicious about why the first method wasn't working. If you had used single quotes instead of double quotes, it wouldn't have compiled. It really depends on exactly what the code was, both the printf and the surrounding code.
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)