I got this to compile, but without producing anything with ./a.out
                
  #include<iostream>
using namespace std;
  string get_csv()
{
       char tmp;        // set up a temporary char
       string string1;  // create the string
        // repeat until EOF or comma
        // read characters
        // if not comma or readline, append to string
        // cin.eof << "Enter a series of characters:  ";
        while(cin.get(tmp))
        {
                if(tmp != ',' && tmp != '\n')
                        string1.push_back(tmp);   // add to the string
     if(tmp == cin.eof())
                        return " ";
                else if (tmp == ',')
                        break;
        }
        return string1;
}
int main(int argc, char *argv[])
{
        string string1;
        while (true)
        {
                string1 = get_csv();
                if (string1 == " ")
                        break;
                cout << string1 << "\t";
        }
          system("Pause");
        return EXIT_SUCCESS;
}
  


Robert Ryan <[EMAIL PROTECTED]> wrote:
          does abyone know get_csv() and how to implement a string with 
get_csv()
thanks
bob

#include<iostream>
#include<vector>
using namespace std; 
int get_csv() {
string string1;
// repeat until EOF or comma
// read characters
// if not comma or readline, append to string
cin.eof << "Enter a series of characters: ";
return string;
}

int main()
{
}

Write a function get_csv() which gets a comma-separated string
from the keyboard including whitespace except for '\n' characters. In other
words, if you call this function and type Happy Valentine's Day,
it will return the string " Happy Valentine's Day" without the comma or
newlines. Write a main function which repeatedly (until end-of-file) asks the 
user to enter a string followed by a comma, calls get_csv(), and prints out the
string it returns. Note: To read whitespace so you can decide whether to add 
it to the string or ignore it, use

char c;
cin.get(c);

This will read the next character whether whitespace or not. If the cin fails
(for example, if the user type Ctrl-Z or Ctrl-D for end-of-file), then get_csv()
should return an empty string (""). Name your program csv.cpp. Hint: First
write what you want the program to do as comment (//) lines in English (and 
maybe have your TA look at it), and then write C++ code to do it.


Write a function get_csv() which gets a comma-separated string
from the keyboard including whitespace except for '\n' characters. In other
words, if you call this function and type
Happy Valentine's Day,
it will return the string " Happy Valentine's Day" without the comma or
newlines. Write a main function which repeatedly (until end-of-file) asks the 
user to enter a string followed by a comma, calls get_csv(), and prints out the
string it returns. Note: To read whitespace so you can decide whether to add 
it to the string or ignore it, use char c; cin.get(c);
This will read the next character whether whitespace or not. If the cin fails
(for example, if the user type Ctrl-Z or Ctrl-D for end-of-file), then get_csv()
should return an empty string (""). Name your program csv.cpp. Hint: First
write what you want the program to do as comment (//) lines in English (and 
maybe have your TA look at it), and then write C++ code to do it.

---------------------------------
Never miss a thing. Make Yahoo your homepage.

[Non-text portions of this message have been removed]



                         

       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.

[Non-text portions of this message have been removed]

Reply via email to