answersLogoWhite

0


Best Answer

You need to put if statement to check presence of comma in the stream. Most likely you have to read data from stream character by character and compare each time with come:

...
char commaCheck = ',';
...
while (cin >> commaCheck)//you can replace cin with your stream
{
...
if (commaCheck == ',')
{
...
}
...

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you read data separated by commas into arrays in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are separators in c plus plus?

Separators include commas, colons, semi-colons and white-space. Semi-colons are used to indicate the end of a code block or to separate one function from the next. Commas are used to separate function arguments, or to separate structure variables and class member initialisation lists (comma-separated lists). Colons are mainly used to signify class inheritance and the start of class initialisation segments. White-space separates a variable type from its name, but is also used to aid the readability of code.


A program for queue ADT by using arrays in c plus plus?

Arrays are not suitable for implementing queues because while they are ideal for adding to the end, the are not ideal for extraction from the beginning. For that you need a deque. Regardless, the STL (standard template library) already provides an efficient queue ADT in std::queue.


What are the advantages of arrays?

Advantages: 1. You can use one name for similar objects and save then with the same name but different indexes. 2. Arrays are very useful when you are working with sequances of the same kind of data (similar to the first point but has a different meaning). 3. Arrays use reference type and so. Disadvantages: 1. Sometimes it's not easy to operate with many index arrays. 2. C environment doesn't have checking machism for array sizes. 3. An array uses reference mechanism to work with memory which can cause unstable behaviour of operating system (unless special methods were created to prevent it) and often even "blus screen" and so on. store the many characters or vales in a single variable.


Can an integer data type in c plus plus stores character value?

no


What is multidimensional array in c plus plus?

A multidimensional array in C or C++ is simply an array of arrays, or an array of an array of arrays, etc. for however many dimensions you want. int a; // not an array int a[10]; // ten int a's int a[10][20]; // twenty int a[10]'s, or 200 int a's int a[10][20][30]; // and so on and so forth...

Related questions

What is the Difference between arrays in c and c plus plus?

Nothing whatsoever. They are exactly the same.


Array in c plus plus must be defined at compil time?

No. Arrays can be defined at runtime, just as they can in C. It's just that it's generally more convenient to use vectors instead of dynamic arrays at runtime, thus arrays are generally used statically, at compile time.


Do you have pointer concept in c plus plus language?

Yes. All string variables are pointers as are other arrays.


What is the C plus plus directive that allows you to refer to classes in a namespace like STD?

A quick and simple way to do this would be to add 'std::' directly in front of the data type that requires it. For example: a vector data type, without the line of code 'using namespace std' would look like this: 'std::vector' (without the inverted commas).


What are separators in c plus plus?

Separators include commas, colons, semi-colons and white-space. Semi-colons are used to indicate the end of a code block or to separate one function from the next. Commas are used to separate function arguments, or to separate structure variables and class member initialisation lists (comma-separated lists). Colons are mainly used to signify class inheritance and the start of class initialisation segments. White-space separates a variable type from its name, but is also used to aid the readability of code.


How do you swap two arrays in c plus plus using string?

You can't. While a string is a character array, an array is not necessarily a string. Treating arrays as if they were strings simply to swap them is madness. The correct way to physically swap arrays A and B is to copy A to a new array, C, then copy B to A, then C to B. If the arrays are the same size this is not a problem. If they are different sizes, you can only swap them if they are dynamic (not static). This means you must reallocate them. To speed up the process, copy the smallest array to C, first. A much better approach would be to point at the two arrays and swap the pointers instead.


A program for queue ADT by using arrays in c plus plus?

Arrays are not suitable for implementing queues because while they are ideal for adding to the end, the are not ideal for extraction from the beginning. For that you need a deque. Regardless, the STL (standard template library) already provides an efficient queue ADT in std::queue.


What are the parts of an expression separated by a plus or minus sign?

terms


What are the advantages of arrays?

Advantages: 1. You can use one name for similar objects and save then with the same name but different indexes. 2. Arrays are very useful when you are working with sequances of the same kind of data (similar to the first point but has a different meaning). 3. Arrays use reference type and so. Disadvantages: 1. Sometimes it's not easy to operate with many index arrays. 2. C environment doesn't have checking machism for array sizes. 3. An array uses reference mechanism to work with memory which can cause unstable behaviour of operating system (unless special methods were created to prevent it) and often even "blus screen" and so on. store the many characters or vales in a single variable.


What part of an algebraic expression separated by a plus or minus sign?

A term.


Is milk plus cornflakes plus fruit equals breakfast a chemical change?

No because they can all be separated afterwards


What is separated by a plus or minus sign and can be a number or a product of a number and variables?

An algebraic expression or equation may be separated by a plus or minus sign, and it can consist of terms that are numbers or products of numbers and variables.