473,396 Members | 1,838 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,396 software developers and data experts.

how to differentiate 1 word or much than 1 word

hi, i'm trying to do this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. string x;
  3. cin>>x;
  4.  
  5. if (x is one word){
  6. something
  7. }else{
  8. something
  9. }
  10.  
  11.  
how can i differentiate between a word or a phrase.

thanks for your help
Mar 24 '07 #1
1 1177
horace1
1,510 Expert 1GB
is a word delimited by space characters? if so
Expand|Select|Wrap|Line Numbers
  1. string x;
  2. cin>>x;
  3.  
reads up to the next whitespace (spaces and newlines) so you will always read words. If you wish to read a line of text use getline()
http://www.cppreference.com/cppstring/getline.html

you can then see if there is a space charcater in the string using find()
http://www.cppreference.com/cppstring/index.html
Mar 24 '07 #2

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

Similar topics

1
by: Markus Ernst | last post by:
Hi I wrote a function that "normalizes" strings for use in URLs in a UTF-8 encoded content administration application. After having removed the accents from latin characters I try to remove all...
4
by: bborden | last post by:
When I save a document in Word that I have transferred from VBA to Word I notice that the "Save As" file name is for, instance, "December 4.doc". Since the date is the first field I print on the...
8
by: Frost | last post by:
Hi All, I am a newbie i have written a c program on unix for line by line comparison for two files now could some one help on how i could do word by word comparison in case both lines have the...
2
by: spidey12345 | last post by:
what i need this program to do is to read paragraphs like "st blah blh test ere se sit blha eere w" and then it will reformat to "st blah...
6
by: Eric Layman | last post by:
Hi, I have fields from textareas. With a click of a button, php is able to grab these fields and by using header(), convert the output to Ms Word doc. But the outcome of the word doc...
1
by: nearestniladri2003 | last post by:
#include <stdio.h> #include <conio.h> void main() { FILE *fp; char a,data;//Just taking 100 bytes not more that that. int i = 0,count = 0; fp = fopen("C:\\mydoc.txt","r"); // Here my...
5
by: JWest46088 | last post by:
I can't figure out how to read a file word by word. I want to open the file and then read it one word at a time. For example, I'm looking for words that start with d. How would I scan each word of...
5
by: Stuudent | last post by:
Hi! Is there possibility to read char* table word by word in C (not C++)? I'm learning C by writing simple HTTP Server on BSD sockets (just for fun). And I want to read info from HTTP header...
9
by: George | last post by:
C with 2 sprained hands. I would nlike to emulate the t4 encoding scheme using the following graphic: * * * * * * ***** o O o o
0
by: Roopa Nagaral | last post by:
Hi, I am working on vb.net... i need to retrieve particular word from word document and display it on vb.net label or textbox... like in word documnet Name : xyz DOB: 13/02/1990 here i v to...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.