Home Answers Viewqa Framework Integers separated by a ", " in a string

 
 


Bob Bob
Integers separated by a ", " in a string
1 Answer(s)      2 years and 4 months ago
Posted in : Framework

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 Pages:
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
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
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
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
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
Series of long Integers
*; public class Fibonacci { public static void main(String[] args) throws... isPrime; } public static void main(String[] args) { Scanner
Mangling Integers,java,java newsletter,tutorial
Mangling Integers 2005-01-31 The Java Specialists' Newsletter [Issue 102] - Mangling Integers Author: Dr. Heinz M. KabutzJDK version: Sun JDK 1.5.0_01... and welcoming. Mangling Integers When I was a kid, I enjoyed
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... of the following program. Program Result: This program takes a complete string or text
Example - Array to String
Java: Example - Array to String Here is a simple, but slow, program to concatenate all of the strings in an array, each separated by a specifed string...() // Convert an array of strings to one string. // Put the 'separator' string
Summary: Methods
Java: Summary: Methods Parameters Method parameters are separated by commas. Parameters are converted to these larger or equal types (int, long... void main(String[] args) signature To decide which method to call, Java looks
Integers
Java NotesIntegers Integers are whole numbers, for example, -35, 0, 2048, .... Integers are represented in binary inside the computer, and in decimal... of primtive integers and two integer classes. Primitive types. The are four types
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
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
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
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
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
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
array and string based problem
array and string based problem  this program is accepting only integers as input but i want to modify it such that it can accept both integers... main(String a[]){ Scanner input=new Scanner(System.in); int array[]=new
array and string based problem
array and string based problem  this program is accepting only integers as input but i want to modify it such that it can accept both integers... main(String a[]){ Scanner input=new Scanner(System.in); int array[]=new
array and string based problem
array and string based problem  this program is accepting only integers as input but i want to modify it such that it can accept both integers... main(String a[]){ Scanner input=new Scanner(System.in); int array[]=new
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
Integer exception in java
. Integers are not objects. The Java utility classes require the use of objects. If you... the character  3)Integer.toString( ) - This return you the string representation...;void main(String[] args) throws IOException {  
Non-atomic Types
. It can be either primitive or derived like strings, integers, decimals, dates... consist of sequence of atomic data types separated by whitespace. Creating a List... is either the integer 1 or the string "One". <myUnion>1
Integer value to string - Swing AWT
Integer value to string  How can we convert an integer type into String ,so that we can select some integers from list and sum them and add...; int i=10;String str =String.valueOf(i);orString str =i+""
Merge Sort String Array in Java
Merge Sort String Array in Java  Hello, I am trying to implement a merge sort algorithm that sorts an array of Strings. I have seen numerous examples of merge-sorting integers but i can not understand how to this with String
JavaScript array join
;  We can put all the elements of an array into a string by using the method join() of JavaScript array object. These elements in the generated string would be separated by a separator.  Syntax of the join() is as given below
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  how to add spaces with string functions.?   Hi... String addSpaceToRight(String s, int n) { return String.format("%1$-" + n + "s", s); } public static String addSpaceToLeft(String s, int n) { return
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
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
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(" "); for(int i=0
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 Regex Methods
+"); // Separated by "whitespace" int sum = 0; for (String t : tokens... Java: String Regex Methods In addition the the Pattern and Matcher classes, there is some support for regular expressions in the String class
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 http

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.