I cannot get the following to compile correctly; #include<stdio.h> #include<stdl
ID: 3641956 • Letter: I
Question
I cannot get the following to compile correctly;
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int i;
char; fullname[20];char first[20];char last[20];
printf("Enter lastname, first or end to quit");
scanf("%s",fullname);
while(strcmp(fullname);
{
for(i=0,j=0;fullnane[i] !=' , ';i++)
last[i] = '; i++;
for(;i<strlen(fullname);i++, j++)
first[j]= fullname[i];
first[j]= '';
printf("Enter lastname, first or end to quit");
scanf("%s", fullname);
}
system("PAUSE");
return 0;
}
the assignment is Write a program using a user-terminated loop that accepts names in Lastname, Firstname order and converts them into Firstname Lastname. The input name should be a single character string. Search for the comma to separate it into two strings to display it in the correct format.
Explanation / Answer
#include #include #include int main(void) { int i,j; char fullname[20], first[20], last[20]; printf("Enter lastname, first or end to quit: "); scanf("%s",fullname); while(strcmp(fullname,"end")){ for(i = 0; fullname[i] != ','; i ) last[i] = fullname[i]; last[i] = ''; i ; for(j = 0; jRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.