How to add characters to reach the maximum size of a char[].
- by Bon_chan
Hi folks,
I have the following part of code :
for(int i=0;i<n;i++)
{
printf("Student %d\n",i+1);
printf("Enter name : ");
scanf("%s",&(student+i)->name);
fflush(stdin);
lengthName = strlen((student+i)->name);
while(lengthName !='\0')
{
}}
when the length is shorter than 10, it will add hyphens until reaching the maximum size.
Ex : John = 6 hyphens will be added
I know how to do it in csharp but can't figure it out in c.
Could some of you give me some lights please?
PS : Oh yes the variable name is char name[10+1] and it a part of the structure called student.