473,289 Members | 1,839 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,289 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 1174
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: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.