473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to divide the strings as a group of characters?

8
I do not know how to divide/read the strings into several groups of characters so that i could place these groups into the vector.
Feb 21 '07 #1
3 2010
horace1
1,510 Expert 1GB
I do not know how to divide/read the strings into several groups of characters so that i could place these groups into the vector.
are you working in C or C++. If C++ you could read successive words into strings which can be stored in a vector, e.g.
Expand|Select|Wrap|Line Numbers
  1.     string s;
  2.     cin >> s;
  3.  
if you typed
hello how are you

the string s would contain the first word "hello"
Feb 21 '07 #2
arf
8
I use C++. What i mean is if i have two strings and each string will end with '\n', how will i read the characters for each string without ignoring the newline?

Example of strings

"3332 2223 2224 5443" //string 1
"6654 5522 3432 6754" //string 2
Feb 21 '07 #3
horace1
1,510 Expert 1GB
I use C++. What i mean is if i have two strings and each string will end with '\n', how will i read the characters for each string without ignoring the newline?

Example of strings

"3332 2223 2224 5443" //string 1
"6654 5522 3432 6754" //string 2
to read a line of text terminated by a \n use genline() see
http://www.cppreference.com/cppstring/getline.html

e.g.
Expand|Select|Wrap|Line Numbers
  1.     string s;
  2.     getline(cin, s);
  3.  
if you typed
hello how are you

the string s would contain the text "hello how are you"
Feb 21 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Paul Prescod | last post by:
I skimmed the tutorial and something alarmed me. "Strings are a powerful data type in Prothon. Unlike many languages, they can be of unlimited size (constrained only by memory size) and can hold...
26
by: William Park | last post by:
How do you compare 2 strings, and determine how much they are "close" to each other? Eg. aqwerty qwertyb are similar to each other, except for first/last char. But, how do I quantify that? ...
42
by: Rigga | last post by:
Hi all, I am wondering why string's are not true objects?.... Let me explain... If i write the code Dim x1 as String = "veg" Dim x2 as String = "veg" If x1 = x2 then
7
by: Paul K | last post by:
I'm writing a small component that needs to be as fast as possible. The component needs to convert a string to decimal during the course of it's processing. However, I need to test the string...
14
by: Samuel R. Neff | last post by:
Why would you cast two strings to objects to compare them? I saw code in an MS sample on MSDN and don't get it. if ( (object)name == (object)attr.name ) { both "name" and "attr.name" are...
14
by: Nick Z. | last post by:
I have a file that I want to read a UTF-16 unicode string from. What is the easiest way to accomplish that? Thanks in advance, Nick Z.
6
by: Broeisi | last post by:
Hello, I wrote the tiny progam below just to understand arrays and strings better. I have 2 questions about arrays and strings in C. 1. Why is it that when you want to assign a string to an...
6
by: Christian Blackburn | last post by:
Hi Gang, When encoding HTML strings it'll convert things like " --> &rsquo and the like using Server.HTMLEncode(). However, is there a command to make sure strings don't contain valid SQL...
40
by: Spiros Bousbouras | last post by:
Do you have an example of an implementation where sizeof(short int) does not divide sizeof(int) or sizeof(int) does not divide sizeof(long int) or sizeof(long int) does not divide sizeof(long long...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.