Question
Can someone point me in the right direction??? I don't know how to be able to use an if function to check for a comma
Can someone point me in the right direction??? I don't know how to be able to use an if function to check for a comma input to differentiate between a First Name Last Name input ot the other Last Name, First Name. I understand that to properly signify the difference a comma needs to be used, so how do I check for a comma in a string?
Write a program that meets these requirements:
Prompt the user to enter a persons first name and last name (on the same line)
Use the fgets function to read in the names and store them in a single string.
The user may enter a name in FirstName LastName format.
The user may also enter a name in LastName, FirstName format (note the comma).
The entered name may be a mix of uppercase and lowercase characters.
Use string I/O functions and/or string library functions to extract the names stored in the original string and put them in two, separate strings (one holds first name, the other holds last name).
Hint: The existence of a comma in the original string determines the name format.
Hint: The sscanf function can be used to extract the names from the original string.
Print out your fully processed first and last names.
Print out the lengths of the first name string and the last name string.
Check if the entered first name is Sarah. Display a message with your comparison result.
Create a new string that concatenates the first name string, the constant string Viking, and the last name string.
Display the concatenated string.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started