how to read a comma delimited file into an array c++
C++
#include <fstream>
#include <sstream>
#include <iostream>
#include <vector>
int main()
{
std::ifstream inFile("registration.txt");
if (inFile.is_open())
{
std::string line;
while( std::getline(inFile,line) )
{
std::stringstream ss(line);
std::string ID, fname, lname;
std::getline(ss,ID,','); std::cout<<"\""<<ID<<"\"";
std::getline(ss,fname,','); std::cout<<", \""<<fname<<"\"";
std::getline(ss,lname,','); std::cout<<", \""<<lname<<"\"";
std::vector<std::string> enrolled;
std::string course;
while( std::getline(ss,course,',') )
{
enrolled.push_back(course); std::cout<<", \""<<course<<"\"";
}
std::cout<<"\n";
}
}
return 0;
}
Also in C++:
- Title
- vprintf
- Category
- C++
- Title
- check for bst
- Category
- C++
- Title
- vector pop back
- Category
- C++
- Title
- error: ISO C++ forbids comparison between pointer and integer [-fpermissive] if(s[i] != "b"){
- Category
- C++
- Title
- C++ int to char*
- Category
- C++
- Title
- how to compare lower case character to uppercase cpp
- Category
- C++
- Title
- is TLE means my code is correct but taking more time to computr
- Category
- C++
- Title
- jump to case label c++
- Category
- C++
- Title
- c++ map find
- Category
- C++
- Title
- file objects in c++
- Category
- C++
- Title
- what is difference between ciel and floor
- Category
- C++
- Title
- how to sort a vector in reverse c++
- Category
- C++
- Title
- new c++
- Category
- C++
- Title
- cube mapping sdl
- Category
- C++
- Title
- c++ random numbers
- Category
- C++
- Title
- c++ function to find minimum element in array
- Category
- C++
- Title
- c++ clear stream
- Category
- C++
- Title
- how initilaize deffult value to c++ class
- Category
- C++
- Title
- C++ and endl
- Category
- C++
- Title
- nan c++ example
- Category
- C++
- Title
- set of vectors c++
- Category
- C++
- Title
- matrix eigen c++ example
- Category
- C++
- Title
- mkdir c++
- Category
- C++
- Title
- is not a nonstatic data member or base class of class
- Category
- C++
- Title
- Runtime Error: Runtime ErrorBad memory access (SIGBUS)
- Category
- C++
- Title
- first prime numbers less than
- Category
- C++
- Title
- string substr c++
- Category
- C++
- Title
- iterate 2d array c++
- Category
- C++
- Title
- least number of coins to form a sum
- Category
- C++
- Title
- error: invalid conversion from 'Node*' to 'int'
- Category
- C++
- Title
- C++ w3schools
- Category
- C++
- Title
- built in function in c++ for binary to decimal
- Category
- C++
- Title
- c++ looping through a vector
- Category
- C++
- Title
- create a dictionary cpp
- Category
- C++
- Title
- convert stirng to int c++
- Category
- C++
- Title
- how to pass an object by reference in c++
- Category
- C++
- Title
- variabili in c++
- Category
- C++
- Title
- binary search in set c++
- Category
- C++
- Title
- c++ multiple inheritance diamond problem
- Category
- C++
- Title
- stringstream in c++ with delimiter
- Category
- C++
- Title
- lambda operator in c++
- Category
- C++
- Title
- C++ user input
- Category
- C++
- Title
- error: invalid use of template-name without an argument list
- Category
- C++
- Title
- zeros of array c++
- Category
- C++
- Title
- inserting an element in an set c++
- Category
- C++
- Title
- pause the console c++
- Category
- C++
- Title
- nearest integer rounding in c++
- Category
- C++
- Title
- create a 2d array c++
- Category
- C++
- Title
- c++ create object
- Category
- C++
- Title
- c++ for loop syntax
- Category
- C++
- Title
- constant variables in c++
- Category
- C++
- Title
- c++ constructor
- Category
- C++
- Title
- maximum possible number atmost k swaps
- Category
- C++
- Title
- user input c++
- Category
- C++
- Title
- time function c++
- Category
- C++
- Title
- opencv compile c++
- Category
- C++
- Title
- Get handle in C++
- Category
- C++
- Title
- length of array in cpp
- Category
- C++
- Title
- expected unqualified-id before 'if'
- Category
- C++
- Title
- residuo en lenguaje c
- Category
- C++
- Title
- insertion sort in c++ program
- Category
- C++
- Title
- how to load from files C++
- Category
- C++
- Title
- how to get a letter from the users string in c++
- Category
- C++
- Title
- c++ read file line by line
- Category
- C++
- Title
- fail() in c++
- Category
- C++
- Title
- passing array to function c++ pointer
- Category
- C++
- Title
- simple timer arduino blynk library error
- Category
- C++
- Title
- iterative inorder traversal
- Category
- C++
- Title
- ceil in c++
- Category
- C++
- Title
- Find the duplicate in an array of N integers.
- Category
- C++
- Title
- unordered_set c++
- Category
- C++
- Title
- time conversion hackerrank solution in c++
- Category
- C++
- Title
- binary search stl in c++
- Category
- C++
- Title
- preorder traversal c++
- Category
- C++
- Title
- initialize int c++
- Category
- C++
- Title
- monotonic deque
- Category
- C++
- Title
- findung the mode in c++
- Category
- C++
- Title
- call by reference c++ example
- Category
- C++
- Title
- c++ compiler for sublime text
- Category
- C++
- Title
- how to convert int to string c++
- Category
- C++
- Title
- c++ code for polynomial addition
- Category
- C++
- Title
- how to put a class in a .h file c++
- Category
- C++
- Title
- how to get size of 2d vector in c++
- Category
- C++
- Title
- how to return a vector c++
- Category
- C++
- Title
- set precision in c++
- Category
- C++
- Title
- power c++
- Category
- C++
- Title
- tree traversal c++ in order
- Category
- C++
- Title
- bellman ford algorithm cp algorithm
- Category
- C++
- Title
- c++ string to vector int
- Category
- C++
- Title
- what are the different ways to traverse a binary tree
- Category
- C++
- Title
- how to make a vector in c++
- Category
- C++
- Title
- cloud hosting
- Category
- C++
- Title
- how to format decimal palces in c++
- Category
- C++
- Title
- how to iterate trough a vector in c++
- Category
- C++
- Title
- how to make a switch case statement in c++
- Category
- C++
- Title
- how to modulo 10^9+7
- Category
- C++
- Title
- how to define a while statement in c++
- Category
- C++
- Title
- setbits
- Category
- C++
- Title
- int max in c++
- Category
- C++
- Title
- matrix class in c++
- Category
- C++