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.
This is so simple that it seems like I must be missing something.
Perhaps you are confused by C#’s (presumed) possession of a first-class string type? No such thing in C, only bare arrays of characters; which is at once tedious (you have to do all the memory management yourself) and liberating (as you see above).