1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#include <iostream>
#include <string>
#include <vector>
using namespace std;
/*Write a program that allows a user to type in tabular data similar to a CSV file, but instead of using commas a
separtor, you should try to detect valid separators. First, let the user type in the line of tabular data. Then
detect possible separator characters by looking through the input for non-number, non-letter, non-space characters.
Find all of these chracters that appear on every single line, and display the user these characters to ask which
one to use. For example, if you see input like this: Alex Allain, webmaster@cprogramming.com John Smith,
john@nowhere.com. You should prompt the user to choose between comma, at sign, and period for the separtor. */
int main ()
{
vector<string>symbol_index (40);
string symbols = "~`!@#$%^&*()-_=+{[}]|:;?/>.<,'\\\"";
string input = "jae.kim@jhykima, I like icecream & water, #coding.";
for (int j = 0; j < symbols.length (); j++)
{
int k = 0;
for (int i = input.find (symbols[j], 0); i != string::npos; input.find (symbols[j], i))
{
symbol_index[k] = symbols[i];
k++;
i++;
}
}
}
|