Im trying to make it output a username that starts with the first 5 letters of their last name, 1st letter of their firs

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Im trying to make it output a username that starts with the first 5 letters of their last name, 1st letter of their firs

Post by answerhappygod »

Im trying to make it output a username that starts with thefirst 5 letters of their last name, 1st letter of their first name,and last 2 digits and of whatever 4 digit number is input.
like if - Michael Jordan 1991
is input, the output is -
What im struggling with is getting the last 2 digits added,tried for loops but for some reason i couldn't get it to work.
this is what i have
#include <stdio.h>#include <string.h>
int main() {
char firstName[50]; char firstName2[5]; char lastName[50]; char lastName2[5]; int digits[5]; int digits2 = 0; scanf("%s", firstName); scanf("%s", lastName); /* for (int i = 0; i < 4; i++) { scanf("%d", &digits); }*/ strncat(firstName2, firstName, 1); strncat(lastName2, lastName, 5); printf("Your login name: %s%s%d", lastName2, firstName2,digits[ ]);
return 0;}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply