Taking my HW to the next level.
Hey, I need to do some simple C++ programming for my first lab assignment. It's relatively easy. I just ask for their name, email, and phone number. lots of cin and couts. yay.
now what I want to do is:
when the user enters their name, I want to check if it's just their first name or their whole name. I'm thinking I search the string of chars for the space character because if it's "John Doe" there's a space between their first and last name. I figured I use a for loop and test if that's true, and if it is, then I want my program to locate the first name and save it to a string and the last name to another string. I have no idea how to do that...
as for the email, I want to write a checker, that checks if it's an actual email address, looking for "@" and ".com"
for the phone number, I will ask the user to type in their number, and it might be 1234567 or 123-4567 or 123.4567, so it's not going to be an int. the variable will be a char type. I want the program to scan the string and take out all the numbers. so if the user types q1e2jn3nj4n5n6jjjjj7, the program will read 1234567.
quick question, I'm using Visual Studio 2008, so is this c++ or visual c++?
Re: Taking my HW to the next level.
Both. Visual C++ is Microsoft's implementation of C++.
Re: Taking my HW to the next level.
char *strchr( const char *s, int c )
I'm thinking I use that to search for the character and use a for loop to output the rest of hte string base on the position of the character in the string.
EDIt: I'm not asking for codes. I jsut want to know which commands I should use. I'll google the commands and see how to properly use it myself.
Re: Taking my HW to the next level.
Re: Taking my HW to the next level.
Why not use idiomatic C++ and use stl. Here is reference to string class and this adds more string operations from boost.