Hello, I need software that reads a full name, consisting of a simple name and a last name, separated by "_" and printed separately.
The code should use the following main function:
#include <stdio.h>
int main(){
char nome[30];
char * sobrenome;
scanf("%s", nome);
sobrenome = extraiSobrenome(nome);
printf("Nome\n%s\nSobrenome\n%s\n",nome, sobrenome );
return 0;
}
I tried to write the extraiSobrenome(nome);
function, but without success:
#include <stdio.h>
#include <string.h>
extraiSobrenome(nome){
int i=0, j=0, aux;
char nova[30], michael[30];
char sobrenome[30];
strcpy(nova, nome);
for(i=0;i<(int)strlen(nova);i++){
if(nova[i]==95){
i++;
break;
}
}
aux=i;
while(i<strlen(nova)){
sobrenome[j]=nova[i];
i++;
j++;
}
sobrenome[strlen(nova)-aux] = '#include <stdio.h>
int main(){
char nome[30];
char * sobrenome;
scanf("%s", nome);
sobrenome = extraiSobrenome(nome);
printf("Nome\n%s\nSobrenome\n%s\n",nome, sobrenome );
return 0;
}
';
return sobrenome;
}
int main(){
char nome[30];
char * sobrenome;
scanf("%s", nome);
sobrenome = extraiSobrenome(nome);
printf("Nome\n%s\nSobrenome\n%s\n", nome, sobrenome );
return 0;
}
The problem is not only to separate the surname, but to change the name too, can you help me?