if (namelist==NULL)
{
namelist=(char**)malloc(sizeof(char**));
namelist[i]=name;
}
else
{
namelist=(char**)realloc(namelist,(i+1)*sizeof(char**));
namelist[i]=name;
}
for(i=0;i<count;i++)
{
printf("%s\t\t%s\n",namelist[i],namelist[i]);
}
The problem is if I enter "abcdefg"
, "abcdefgh"
and "abc"
as input, I will get
abcdefg abcdefg
abcdefgh abcdefgh
abc abc
Is there any way to get the second "abcdefgh"
to get in line as the second "abcdefg"
and "abc"
?
stop using TAB characters (\t) as separators, use proper format specifications instead, if you want your strings to start at 20th column, write:
printf( "%-20s%s", namelist[i],namelist[i]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With