Generating username from first name and last name in C -


i writing c program generate userid's given file (users). file has each user's first , last names each line (eg. "john smith", "steve mathews" etc). following while loop reads each line users , prints in console in lowercase. in case, single_line holds names in lower case.

while(!feof(fp)) {         fgets(single_line, 80, fp);         for(int = 0; single_line[i]; i++){           single_line[i] = tolower(single_line[i]);         }         char f_letter = single_line[0];         char r_letters[20]; } 

now, want create username each single_line first letter of first name , remaining letters of last name. far, f_letter holds first letter of first name, how can make r_letters hold remaining letters of last name?

char first_name[81]; char last_name[81]; char user_name[82]; while(!feof(fp)) {         if(fscanf(fp, "%80s %80s", first_name,last_name) == 2){              for(i = 0; < strlen(first_name); i++){               first_name[i] = tolower(first_name[i]);             }             for(i = 0; < strlen(last_name); i++){               last_name[i] = tolower(last_name[i]);             }              sprintf(user_name, "%c%s", first_name[0], last_name);         } } 

Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -