Any C++ programmers here? Help Needed...

FSP

Banned
Joined
Jun 19, 2015
Messages
14,284
Reputation
1,108
Daps
42,300
when's it due breh? :mjlol:

It's gon be hell when you start getting very hard assignments..

I had to do an assignment building an entire goddamn poker game in an intro comp sci course WTF?!

And it doesn't get any harder here on out.
:deadrose: <- this would have been me. Like, I would have literally died.
 

Illuminatos

#OVOXO
Joined
Jun 19, 2012
Messages
46,102
Reputation
4,063
Daps
194,443
Reppin
NULL
when's it due breh? :mjlol:

It's gon be hell when you start getting very hard assignments..

I had to do an assignment building an entire goddamn poker game in an intro comp sci course WTF?!

And it doesn't get any harder here on out.

It was due on Wednesday but if I hand it in on Monday I only lose 5 points. :snoop:

The workload is ridiculous. I have another assignment due next Wednesday and my final is on Wednesday as well. :sadcam:
 

Dr. Acula

Posts on Dapcity.com
Supporter
Joined
Jul 26, 2012
Messages
26,962
Reputation
9,402
Daps
144,280
You should use stringstream and use that to replace the get function. Get only gets a charcter at a time, where as if you use string stream you can do it a word at a time and like other said, manipulate the string like an array with [].

So for example, feed a line into the stringstream, then output the string stream into a string variable. Store the first letter into a char. Delete the first character with the erase function string::erase - C++ Reference. Concatenate that previously mention char to that string. Then you can concatenate ay onto the end of it instead of doing all these else then if statements. This would be inside a while loop until you get to the end of the stringstream line. Then you'll need to make it pull the next line into the stringstream.

As far as making sure your output file is formatted correctly, you'll have to mess with the code a bit to get it to look like your professor expects. This should be a simple loop to handle this portion.

I'll try to draw something up if you need some cleared up regarding what I said above. If you do it word by word and treat the strings as arrays, then I think it will make it a lot easier for you.
 

TRAP AMERICAN TV

TRAP GOLD
Joined
Nov 17, 2015
Messages
2,970
Reputation
-1,305
Daps
7,965
I ain't want to do this but I'm about to go crazy over here. :whoa::bryan:

Basically I have to take the Gettysburg Address and convert it into pig latin. :snoop:



I have to take the first letter of each word, put it at the end of the word and add an "ay" at the end. So for example "Four score and seven" would be "Ourfay coresay ndaay evensay." After that I have to count the number of words, letters and characters in the file.

The 2nd part is easy but the actual converting the text into pig latin has me losing my mind. I've been going at it for the last three days and I just can't figure it out.

The professor says to process each letter one at a time but I don't know how to store the letter and put it into the end of the word. :jbhmm:

This is what my main is looking like

LRktka1.png



Basically this puts an ay at the end of every word except for words that start a new line. :snoop:

I just need help with the converting to pig latin part, I can do the word/letter counting. I'm not asking you to do my assignment but any hints/advice would be helpful.:martin:

EDIT: Btw this is what I get when I run the program in the OP.

WO3i1TG.png
Did you get it yet?
 

Dr. Acula

Posts on Dapcity.com
Supporter
Joined
Jul 26, 2012
Messages
26,962
Reputation
9,402
Daps
144,280
That's fukked up. Learning how to use documentation and research is 90% of programming.
I understand it. My intro courses were the same way. Once you're in higher level courseand pass the intro course the professors are more liberal. But in introduction to programming courses they want you to do it exactly as they say. They want you to work within certain parameters to develop good techniques.

That is one area that its better to learn in the classroom than on your own. While there are people who have programmed since they were in middle school, they develop their technique through an amalgamation of sources and as a result their programming is like building a structure with duck tape. Intro courses force rigidity to force you to develop good coding techniques that don't look like shyt.
 

Illuminatos

#OVOXO
Joined
Jun 19, 2012
Messages
46,102
Reputation
4,063
Daps
194,443
Reppin
NULL
You should use stringstream and use that to replace the get function. Get only gets a charcter at a time, where as if you use string stream you can do it a word at a time and like other said, manipulate the string like an array with [].

So for example, feed a line into the stringstream, then output the string stream into a string variable. Store the first letter into a char. Delete the first character with the erase function string::erase - C++ Reference. Concatenate that previously mention char to that string. Then you can concatenate ay onto the end of it instead of doing all these else then if statements.

As far as making sure your output file is formatted correctly, you'll have to mess with the code a bit to get it to look like your professor expects. This should be a simple loop to handle this portion.

I'll try to draw something up if you need some cleared up regarding what I said above. If you do it word by word and treat the strings as arrays, then I think it will make it a lot easier for you.

Breh, thank you. :lawd: I had the thought of using strings but I wasn't that comfortable with it. I was more familiar with get and put. :snoop:

Breh can you please draw that up too? :salute:

Actually I think he's only limited to what's taught in class. If he utilizes techniques not taught in class then the professor isn't going to accept it.

....At least that's how it was with my teacher.

We did strings and arrays but we used the string library not stringstream. Not sure the difference. :patrice:

Plus dude always tells us to use Google if we don't know something. :lolbron:
 

Dr. Acula

Posts on Dapcity.com
Supporter
Joined
Jul 26, 2012
Messages
26,962
Reputation
9,402
Daps
144,280
Breh, thank you. :lawd: I had the thought of using strings but I wasn't that comfortable with it. I was more familiar with get and put. :snoop:

Breh can you please draw that up too? :salute:



We did strings and arrays but we used the string library not stringstream. Not sure the difference. :ptrice:
On second though I have to agree with my dude @Tunez You have to figure this out somewhat so I'm not going to do the whole thing.

Let me ask, are you familiar with stringstreams at least?

If not check this out and look at the example on how it works.

stringstream::stringstream - C++ Reference

I can teach you how to fish a bit on this one if you need help with this part.
 

PikaDaDon

Thunderbolt Them Suckers
Joined
Oct 13, 2012
Messages
9,359
Reputation
2,323
Daps
25,321
Reppin
NULL
We did strings and arrays but we used the string library not stringstream. Not sure the difference. :patrice:

Plus dude always tells us to use Google if we don't know something. :lolbron:

I believe 'string' is a C class. While 'stringstream' is like the modern c++ version of it that's derived from iostream. Most people just use string.
 
Top