Code:
printf("Enter the number of labels you want to make: ", n);
scanf("%d", &n);
The user enters a number and then enter.
"scanf()" reads the number, but leaves the newline in the input buffer.
(Side note: What is that 'n' doing in your "printf()"? You don't have any matching format specifiers - i.e., you're not printing any variables.)
Code:
{printf("Enter your full name:\n ");
gets(label[i] .name);
When you get to the first "gets()", it reads the newline that is still in the input buffer. This makes it seem as though that prompt is being skipped - but it's not.
More information on that here: FAQ > How do I avoid a "dangling" newline when reading single character user input? - Cprogramming.com
And read this, as well: FAQ > Why gets() is bad / Buffer Overflows - Cprogramming.com
When all the information is printed out, it doesn't exactly line up with their titles either. I need help fixing this as well.
You're using tabs to line up the columns. But if a string is longer than a tab stop, the tab character brings it another tabstop forward. A good way around this is to use field width specifiers in your string outputs. Run the following example to see.
Code:
#include <stdio.h>
int main(void)
{
char *string_1 = "short";
char *string_2 = "longer_line";
char *string_3 = "longest_line_ever";
// your method
// see how they don't line up nicely
// if the strings are too long
printf("Line 1\tLine 2\tLine 3\n");
printf("%s\t",string_1);
printf("%s\t",string_2);
printf("%s\t",string_3);
printf("\n\n");
// another method
printf("%-18s %-18s %-18s\n","Line 1","Line 2","Line 3");
printf("%-18s ",string_1);
printf("%-18s ",string_2);
printf("%-18s ",string_3);
printf("\n\n");
return 0;
}
The number between the '%' and the 's' specifies the minimum width of the string. If shorter than this width, the string is padded with spaces. Also note how that number is negative. If positive, the strings default to right-justified (that is, the string is padded at the beginning). By making it negative, it is left-justified (the string is padded at the end).