Hello everyone,
I'm a total self-taught (so far) newbie here, so please bear with me. I have almost a hundred names in a text file that I want to convert to email addresses and save to another file. I seem to have it working, but it doesn't print the full names in the email prefix. The output I'm looking for is Doe_John@livebrandm, but I'm only getting D_J@livebrandm. I'm not sure what I should specifically be reading up on that applies to this directly. I would appreciate any help with this.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *fpin=fopen("namesIN.txt", "r");
FILE *fpout=fopen("emailOUT.txt", "a");
char first[20],last[20],inbuff[1500];
if((fpin=fopen("namesIN.txt","r"))==NULL)
{
printf("\nCannot open input file");
exit(1);
}
if((fpout=fopen("emailOUT.txt","a"))==NULL)
{
printf("\nCannot open output file.txt");
exit(2);
}
while(fgets(inbuff,1500,fpin) !=NULL)
{
sscanf(inbuff,"%S%S",first,last);
printf("%s_%[email protected]\n",last,first);
fprintf(fpout,"%s_%[email protected]\n",last,first);
}
fclose(fpin);
fclose(fpout);
return 0;
}
namesIN.txt