Write a program, containing 3 functions that will ask the user for his or her email address and print out the
● The user's name or ID
● The user's character site type. Display the specific name for all 3-character site types.
I am at lost!
cout << "Your user Id is :" << ID;
ID was never declared anywhere
Strings in C++ don't have an 'IndexOf' function. In this case, you'd use
string test = "test"; int test_index = test.find('s'); cout << "'test' index of 's': " << test[test_index] << endl;
string domain = e_mail.Substring(indexOfAt + 1);
C++ uses 'substr' as the function name for substring.
You may have noticed the naming convention for C++ libraries is lowercase
('find' instead of 'Find', 'substr' instead of 'Substr' etc...).
You can use
find() to search for the '@' and that will give you the index of that symbol. Then use that index to print everything before it or after it.
string email = "[email protected]" int at_index = email.find("@"); cout << "Before @: " << email.substr(0, at_index) << endl; cout << "After @: " << email.substr(at_index + 1, email.length() - 1) << endl;
you may need to add or subtract 1 to at_index in the
substr function, I don't know if
substr is "up to index" or "up to and including index".
main.cpp is the file name. That means the error in the in that file, not another one.
74 is the line number. Ignore the
45. Just pay attention to the first number.
error: use of undeclared identifier ID
So in the
main.cpp file on line 74,
ID is undeclared. That means the compiler doesn't know what it is.
- Also, use