Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > ignore funtiction?

Reply
Thread Tools

ignore funtiction?

 
 
Luis
Guest
Posts: n/a
 
      06-25-2003
Please help, this is due at 11:59 PM tonite. Thanks



Write a program that reads a person's name from the keyboard in the format
First Middle Last. It should then (1) print each of the names on a separate
line and (2) print the person's initials on the fourth line. Assume that
each person has exactly 3 names, that the first name begins in the first
position on a line (there are no leading blanks) and that the names are
separated from each other by a single blank.

Do not use arrays in this assignment.



SO far i gigured out only how to print out the initials, but i can't figure
out how to get each part of a name as a seperate string. Can any one help me
out? here is my source so far

#include <iostream>
#include <string>


using namespace std;

int main ()
{

char m;
char l;
char f;



cin>>f;
cin.ignore(100,' ');
cin>>m;
cin.ignore(100,' ');
cin>>l;

cout<<f<<m<<l<<endl;



return 0;
}






 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      06-25-2003
"Luis" <(E-Mail Removed)> wrote...
> Please help, this is due at 11:59 PM tonite. Thanks
>
>
>
> Write a program that reads a person's name from the keyboard in the format
> First Middle Last. It should then (1) print each of the names on a

separate
> line and (2) print the person's initials on the fourth line. Assume that
> each person has exactly 3 names, that the first name begins in the first
> position on a line (there are no leading blanks) and that the names are
> separated from each other by a single blank.
>
> Do not use arrays in this assignment.
>
>
>
> SO far i gigured out only how to print out the initials, but i can't

figure
> out how to get each part of a name as a seperate string. Can any one help

me
> out? here is my source so far
>
> #include <iostream>
> #include <string>
>
>
> using namespace std;
>
> int main ()
> {
>
> char m;
> char l;
> char f;


Declare them as 'string'.

>
>
>
> cin>>f;
> cin.ignore(100,' ');
> cin>>m;
> cin.ignore(100,' ');
> cin>>l;


Drop the 'ignore's.

>
> cout<<f<<m<<l<<endl;


To output each of them on a separate line you need a line
separator between them, don't you?

Now, regarding the initials, what are they? Each initial
is the very first character of each name, right? So, output
the initials by outputting the very first character in each
string.

>
>
>
> return 0;
> }
>
>
>
>
>
>



 
Reply With Quote
 
 
 
 
Andre Kostur
Guest
Posts: n/a
 
      06-25-2003
"Luis" <(E-Mail Removed)> wrote in news:4jpKa.18096$Fy6.5818@sccrnsc03:

> Please help, this is due at 11:59 PM tonite. Thanks
>
>
>
> Write a program that reads a person's name from the keyboard in the
> format First Middle Last. It should then (1) print each of the names
> on a separate line and (2) print the person's initials on the fourth
> line. Assume that each person has exactly 3 names, that the first name
> begins in the first position on a line (there are no leading blanks)
> and that the names are separated from each other by a single blank.
>
> Do not use arrays in this assignment.
>
>
>
> SO far i gigured out only how to print out the initials, but i can't
> figure out how to get each part of a name as a seperate string. Can
> any one help me out? here is my source so far
>
> #include <iostream>
> #include <string>
>
>
> using namespace std;
>
> int main ()
> {
>
> char m;
> char l;
> char f;
>
>
>
> cin>>f;
> cin.ignore(100,' ');
> cin>>m;
> cin.ignore(100,' ');
> cin>>l;
>
> cout<<f<<m<<l<<endl;
>
>
>
> return 0;
> }


Well..... first thing to note is that you're reading into variables of
type 'char'. char can only hold one character. Look up a standard type
named "std::string".
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      06-25-2003
"E. Robert Tisdale" <(E-Mail Removed)> wrote...
> Andre Kostur wrote:
> > Luis wrote:
> >
> >>Do not use arrays in this assignment.

> >
> > Well..... first thing to note is that you're reading into variables of
> > type 'char'. char can only hold one character.
> > Look up a standard type named "std::string".

>
> Isn't a std::string an array?


No, it isn't. Are you trolling again?


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ignore outlook users Skratz Firefox 8 05-05-2005 07:15 PM
Ignore/Kill-file in Thunderbird newsreader Ranjit Firefox 1 08-20-2004 05:19 AM
Ignore + TEST + Ignore SpooderStank Computer Support 2 04-08-2004 11:26 AM
wlftg17 modelsim temp file beeing too big (corret post, ignore the old post) Oleg VHDL 0 04-05-2004 03:31 AM
Searching for Exact Phrase - should I ignore the ignore words? Rob Meade ASP General 6 03-01-2004 11:28 AM



Advertisments