Integers separated by a ", " in a string

Integers separated by a ", " in a string

How do I get integers separated by a ', ' in C++ in a string? Ex. string=1, 2, 3; //something to find the integers and put them in array a cout<

output: 123

View Answers

January 6, 2011 at 1:04 PM

Hi Friend,

Try this:

#include <iostream>
#include <string>
using namespace std;

int main () 
{
    string str = "1,2,3";

    string::iterator It = str.begin();

    while ( It != str.end() )
    {
        if ( *It == ',' )
            *It = ' ';
        cout << *It++;
    }
    cout << endl;

    return 0;
}

Thanks









Related Tutorials/Questions & Answers:
Integers separated by a ", " in a string
Integers separated by a ", " in a string  How do I get integers separated by a ', ' in C++ in a string? Ex. string=1, 2, 3; //something to find the integers and put them in array a cout< output: 123   Hi Friend
Java arraylist to comma separated string
arrayList is converted into the comma separated string. For this take one by one element from the arrayList. Then add it to the String array. Example of Java Arraylist Comma Separated String import java.util.ArrayList
Advertisements
how to find the sum of integers in a string of sentence in java
how to find the sum of integers in a string of sentence in java  how to find the sum of integers in a string of sentence in java for e.g:--> abc d 2 3 21 the output should be 2+3+21=26 (adsbygoogle
integers
integers  an application that finds the smallest of several integers. assume the first value read specifies the number of values to input from the user. please help
INTEGERS
application that will input the kms driven and litre of fuel used (both as integers
Sum of integers
the user and displays i) the sum of all even integers between 1 and the input value, both inclusive. ii) The sum of all odd integers between 1 and the input value both inclusive Example: User enters 7. Sum of even integers = 2+4+6 = 12 Sum
integers
Parsing Character-Separated Data with a Regular Expression
to split String data (separated by "," or "and/or"... Parsing Character-Separated Data with a Regular Expression... string or text with the many separation of words and detects every comma
ModuleNotFoundError: No module named 'django-separated'
ModuleNotFoundError: No module named 'django-separated'  Hi, My... named 'django-separated' How to remove the ModuleNotFoundError: No module named 'django-separated' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'artisinal_integers'
ModuleNotFoundError: No module named 'artisinal_integers'  Hi, My... named 'artisinal_integers' How to remove the ModuleNotFoundError: No module named 'artisinal_integers' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'artisinal_integers'
ModuleNotFoundError: No module named 'artisinal_integers'  Hi, My... named 'artisinal_integers' How to remove the ModuleNotFoundError: No module named 'artisinal_integers' error? Thanks   Hi, In your
Series of long Integers
*; public class Fibonacci { public static void main(String[] args) throws... isPrime; } public static void main(String[] args) { Scanner
STRING.....
STRING.....  plzz sent me d code for counting vowels in a string... gui programme
string
string   difference detween "public static void main (String[] args) " and "public static void main (String args[])" in java but it executes both... "String args[]" can mean a "string array called args which is an array
string
string  String helloString = new String(helloArray); System.out.println(helloString); i am unable to understand this. could u plz explain
string
string  a java program using string function to input any string... ArrangeStringAlphabetically { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter string
String
String  how to add spaces with string functions.?   Hi... { public static String addSpaceToRight(String s, int n) { return String.format("%1$-" + n + "s", s); } public static String addSpaceToLeft(String s, int n
String
characters in string?   import java.util.*; class RemoveDuplicateCharatcersFromString { public static String removeDuplicates(String s... < s.length(); i++) { String st = s.substring(i, i + 1
String
String  write down the code of remove any character from a given string without using any string function   please give me the code of remove any given character from a given string without using function
string
string  a java program to input a string and display the string...*; import java.io.*; public class FirstLetter{ public static String capitalizeFirstLetter( String str ) { final StringTokenizer st = new StringTokenizer( str
string
*; class ExtractWords { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter String: "); String st=input.nextLine(); String str[]=st.split
string
string   just i want to a program in a short form to the given string in buffered reader for example input string: Suresh Chandra Gupta output: S. C...; public class StringTest { public static void main(String [] args
string
string  write a program to accept the string and store the reverse stream into another array and print
string
string  java prgm to find total occurence of a given string pattern in a sentence
string
string  java prgm to find total occurence of a given string pattern in a sentence
String
String  write a program using string it should replace 'c'char to integer number as 1 in whole source
String
String  How to Convert sunnapu gopal to Sunnapu Gopal in java using String
String
String  how to print in between numbers if the question "String s = "1,2,3,4,5,6,8,-25"" out must be 1 2,3,4,5,6,7,8,9,10,upto25
string
and also displaying that contain word? Like I want to find "a" in the string... and a character. It then count the occurrence of that character in the string and display... String_Example { public static void main(String[] args
string
string  program for String reverse and replace in c,c++,java e.g.Input:10,20,hello output:hello;20;10   Hi Friend, Try the following java...(String[] args) { String array[]=new String[5]; Scanner input
string
string  a java program using string function that computes your initials from your full name and display them   Please visit the following links: http://www.roseindia.net/tutorial/java/core/printInitials.html
string
string  a java program using string function and access modifiers to automate the insurance company which will have to manage the information about policy holders Data Members: 1)Policy No 2)Name of policy holder 3)Address 4
Maven Repository/Dependency: com.almworks.integers | integers
Maven Repository/Dependency of Group ID com.almworks.integers and Artifact ID integers. Latest version of com.almworks.integers:integers dependencies. # Version Release Date 1
java matching array of integers - Java Beginners
token is assigned a vlaue in integers and stored in an array. the consecutive array of integers occurring similarly have to be found out. and depending upon... for finding similar consecutive array of integers
how to find [count the number of integers whose value is less than the average value of the integers]
how to find [count the number of integers whose value is less than the average value of the integers]  Construct an algorithm that will prompt... amount to the screen integers from an operator at a terminal, and count the number
write a java program to find the summation of all the integers entered on command line
write a java program to find the summation of all the integers entered... the integers entered on command line? How to write Java program for summation of all the integers entered on command line? Thanks   Hi, Example program
Printing the integers before and after - JSP-Servlet
Printing the integers before and after  Hi, I'm trying to print out the integers before and after generated random number, and also stating it as either even or odd, but it does not seem to work. Pls advise on my code below
Program to read 2 integers using oops concepts
Program to read 2 integers using oops concepts  Write a program to read two integers with the following significance. ? The first integer value represents a time of day on a 24 hour clock, so that 1245 represents quarter
how to use comma separated value list in the where clause oracle
how to use comma separated value list in the where clause oracle  Hi, how to use comma separated value list in the where clause oracle Thanks   HI, Following code will help you: select * from employee where id
STRING FUNCTIONS
a string and 2 integers from user. It then changes the case of characters at those indices as specified by 2 integers entered by the user. --- if you do have...STRING FUNCTIONS  HERE IS THE QUESTION THAT I HAVE IN MY INFORMATICS
Parsing string in objective c
Parsing string in objective c  Hi, How can i parse a string in Objective c?? Thanks.   Parsing string in objective c This example will also help you to separate the strings separated by one component
Maven dependency for com.almworks.integers - integers version 1.1.2 is released. Learn to use integers version 1.1.2 in Maven based Java projects
of integers released The developers of   com.almworks.integers - integers..., the released version of  com.almworks.integers - integers library is 1.1.2. Developer can use this version ( com.almworks.integers - integers version 1.1.2
String Array - Java Beginners
, as to by which method can I separate the Integers from this Array of String...String Array  From where can I get, all the functions that are needed for me to manipulate a String Array. For Example, I had a String Array ("3d4
string array based problem
string array based problem  R/sir, firstly thanks to help me so much. but now it can sort string very well but in case of integers as it treats integers here as string, it sorting like this: i/p: 12 14 11 3
reverse words in a string(words seperated byone or more spaces)
reverse words in a string(words seperated byone or more spaces)  reverse words in a string(words separated by one or more spaces
(ii) String and String Buffer Class
String and String Buffer Class  differences between : String and String Buffer Class
(ii) String and String Buffer Class
(ii) String and String Buffer Class  difference between String and String Buffer Class
(ii) String and String Buffer Class
String and String Buffer Class  difference between String and String... between String and StringBuffer 1) String object is immutable whereas StringBuffer objects are mutable. 2) String objects are constants
String Ques
String Ques  what is difference between String str="abc"; and String str=new String("abc");   Hello Friend, Differences: 1)String str=new string("abc") creates two objects, one in heap memory and one in string
String Array - Java Beginners
, as to by which method can I separate the Integers from this Array of String...String Array  From where can I get, all the functions that are needed for me to manipulate a String Array. For Example, I had a String Array ("3d4

Ads