My question is y am i getting a garbage ouput when i compile this
Code:#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main ( )
{
system("cls");
printf("%-20s Description, %-10s Smarties\n\n");
getch();
}
Printable View
My question is y am i getting a garbage ouput when i compile this
Code:#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main ( )
{
system("cls");
printf("%-20s Description, %-10s Smarties\n\n");
getch();
}
Because you meant to write:
There's no sense in telling printf that you're going to pass it 2 strings if you don't pass it 2 strings.Code:#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main ( )
{
system("cls");
printf("%-20s %-10s\n\n", "Description", "Smarties");
getch();
}
because you are lucky. I would think the correct output for this progrma will be a crash...
don't even try to mismath format of scanf/printf and parameters you pass
i think i have two strings which is description and smarties thought am i wrong??
what is between "" counts as one string, so no - you have only one format string
Which means, at the end, that you have no strings at all as parameters -- your format string is there, but your format string needs two parameter strings, one for each %s, and both of those are just plain not there.