473,657 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with string sparsing.

1 New Member
ok guys this is like my last resort im already 1 day late on this project and i really cant afford to drop this class this block im in datastructers which is kickin my butt already but anyway help if you can and i will really appreciate it.

heres the project...

Your task, in this first iteration, is to write a program that parses user input. There are some basic <<verb>> <<noun>> and <<verb>> <<adverb>> <<noun>> combinations that you should address. See the above text for examples. What I want this project to do is to take user input and show, on the screen the parsed (or tokenized) list of inputs. For example, if the user enters: Take Letter. I want to see on the screen:
<< verb>> Take
<<noun>> Letter
If the user enters Attack Troll with Sword, I want to see on the screen:
<<verb>> Atack
<<noun>> Troll
<<adverb>> With
<<noun>> Sword.
This program MUST use a free function called UserInput. This is a simple project designed to get you back into the mood of programming. This project MUST be done in the Unix environment


heres the code i already have, it compiles and sparses the words perfectly but doesnt input the noun, verb, adverb oart. i also have to put in a loop that will run the program until the user asks to exit. im not at all askin anyone to do this program for me but any help would be greatly appreciated. you have no idea. thanks in advance guys and gals.



#include <iostream>
#include <string>

using namespace std;

void UserInput(strin g &out);

int main()
{

//do{

string max;
UserInput(max);

return(0);

} //Closes main

void UserInput(strin g &max)
{

char input[80];
char newstring[4][80];
int wordCount = 0;
int NewWordCounter = 0;
int NumberOfWords = 0;



for(int rowCount = 0; rowCount < 5; rowCount++)
{
for(int ColCount = 0; ColCount < 81; ColCount++)
newstring[rowCount][ColCount]='X';

}

cout<<"> ";
cin.getline(inp ut, 80);


// This for loop takes a two-dimensional array of characters and parses it into tokens

for(int x = 0; x < 80; x++) // 80 possible characters on a line
{
newstring[wordCount][NewWordCounter]=input[x]; // newstring[0][0] to the first character
if(input[x] == ' ')
{
NumberOfWords++ ;
newstring[wordCount][NewWordCounter]='\0'; // we have to enter the string terminator
wordCount++; // since I hit a space - I must be onto a new word
NewWordCounter = -1; // This is used for the row of my newstring 2D array
}
NewWordCounter+ +;

if(input[x]=='\0')
break; // Why keep going if I have reached the last character -- let's break
}

cout<<"There are "<<NumberOfWord s + 1<<" words in the string. They are: "<<endl;

for (int counter = 0; counter < NumberOfWords + 1; counter++)
{
cout<<newstring[counter]<<endl;
}


}
//while(UserInput != exit);
Nov 21 '06 #1
0 1209

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

Similar topics

6
4331
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing result in any way. Who can help me, I thank you very very much. list.cpp(main program) //-------------------------------------------------------------------------- - #pragma hdrstop #pragma argsused
7
2383
by: Alan Bashy | last post by:
Please, guys, In need help with this. It is due in the next week. Please, help me to implement the functions in this programm especially the first three constructor. I need them guys. Please, help me. This was inspired by Exercise 7 and Programming Problem 8 in Chapter 3 of our text. I have done Exercise 7 for you: Below you will find the ADT specification for a string of characters. It represents slightly more that a minimal string...
1
574
by: wukexin | last post by:
I write my own class Cfile, I want to know what about implement ctime().Who help me? My use function ctime, I sign it with $$$. my class Cfile: #------------------------ file.h #--------------------------- #include <io.h> #include <ctime> #include <string>
3
3351
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With numarray, help gives unhelpful responses:
6
4984
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a PDF. It works fine so far....
16
2002
by: Allen | last post by:
I have a class that returns an arraylist. How do I fill a list box from what is returned? It returns customers which is a arraylist but I cant seem to get the stuff to fill a list box. I just learning and really need some help bad. Public Shared Function GetAll() As ArrayList Dim dsCustomer As New DataSet() Dim sqlQuery As String = "SELECT Name, Address, PhoneNo " & _ "FROM CustomerTable" Try
1
3705
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am attach this script files and inq files. I cant understand this error. Please suggest me. You can talk with my yahoo id b_sahoo1@yahoo.com. Now i am online. Plz....Plz..Plz...
22
2177
by: KitKat | last post by:
I need to get this to go to each folders: Cam 1, Cam 2, Cam 4, Cam 6, Cam 7, and Cam 8. Well it does that but it also needs to change the file name to the same folder where the file is being grabbed, BUT it doesn't. I have tried and tried.....please help example: C:\Projects\Darryl\Queue Review Files\2-24\Cam 7\Cam7-20060224170000-01.jpg Cam7 but all I keep getting is Cam1, as the beginning of the jpg name,...:( HELP!
6
4025
by: JonathanOrlev | last post by:
Hello everyone, I have a newbe question: In Access (2003) VBA, what is the difference between a Module and a Class Module in the VBA development environment? If I remember correctly, new types of objects (classes) can only be defined in Class modules.
0
8844
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.