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

FSP

Banned
Joined
Jun 19, 2015
Messages
14,284
Reputation
1,108
Daps
42,300
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 they don't look like shyt.
That's me :dead:

That duct tape be workin :ehh:
 

Illuminatos

#OVOXO
Joined
Jun 19, 2012
Messages
46,102
Reputation
4,063
Daps
194,443
Reppin
NULL
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.

In class we just used #include <string> library. Never used stringstream. :manny:
 

Afro

Student of life
Supporter
Joined
Feb 8, 2016
Messages
14,577
Reputation
7,369
Daps
57,777
I mean, folks also say to go to stack overflow right? Google is your best friend when programming.
 

BrothaZay

Non-FBA. AdosK
Supporter
Joined
May 5, 2012
Messages
65,342
Reputation
6,740
Daps
225,856
Reppin
The suburbs
Damn I would never think the dude in the semi is the one worried about dying :patrice:
Probably won't die but you'll end up in an accident. Lose your license, get sued and be broke.

Think about driving a truck(especially if its a stick shift) alotta things that cars do can fucc you up and put you in a dangerous situation, even if just for a second
 

PikaDaDon

Thunderbolt Them Suckers
Joined
Oct 13, 2012
Messages
9,359
Reputation
2,323
Daps
25,321
Reppin
NULL
Probably won't die but you'll end up in an accident. Lose your license, get sued and be broke.

Think about driving a truck(especially if its a stick shift) alotta things that cars do can fucc you up and put you in a dangerous situation, even if just for a second

Who's the fat fukk in your avatar?
 

aXiom

Maximized Potential
Joined
May 1, 2012
Messages
11,666
Reputation
8,526
Daps
69,817
Reppin
Parc fermé
Haven't fukked with c++ in about 5 years..

Code looks like you're appending the whole file instead of just individual words??

it would probably be easier to do a for loop that loops based on the blank space before/after each word and then append each with something like:

Code:
string pLat = "ay";
string str1 = "Turnt";
string str2 = str1.substr(0,1);  // this should return "T"
string str3 = str1.substr(1);  // this should return "urnt"


string lat = str3 + str2 + pLat; // this should return "urntTay"

This could be completely fukked code though :lolbron:
 

FSP

Banned
Joined
Jun 19, 2015
Messages
14,284
Reputation
1,108
Daps
42,300
I have to finish this homework, finish my next homework and then study for my final by Wednesday. :childplease:



But in the real world you have access to computers. :patrice:
Yeah you or your professor is vastly underestimating the time it's supposed to take you to solve shyt. Being stuck for 3 days on something is actually quite normal and expected. You need to give yourself four times as long as you think it'll take, and since you're a beginner, probably 10x as long and that's not an exaggeration.
 

Double J

Banned
Joined
May 11, 2012
Messages
1,929
Reputation
-675
Daps
5,266
Breh this isn't even that hard. I don't know C++ but I can give you the basic solution in Java and you can translate it to C++.

Code:
public static String getty(String str) {
   String s = "";
  
   s = str.substring(1) + str.charAt(0) + "ay";
  
   return s;
}

That method takes in a word and return the word with the first letter moved to the end and "ay" added to the end.
 

Dr. Acula

Posts on Dapcity.com
Supporter
Joined
Jul 26, 2012
Messages
26,962
Reputation
9,402
Daps
144,280
In class we just used #include <string> library. Never used stringstream. :manny:
:francis:
Damn dude don't want to give you the answer here honestly.

However I'll give you a quick logic breakdown to get your brain ticking at least. Any loops and things you need to create and formatting you have to figure out your own:

  • Add the appropriate libraries for the stringstream and string. <sstream> and <string>
  • Create some string variables. One to hold the line of text that you'll read in with while(getline(infile,buffer)) with buffer being the possible name of one of your string variables.
  • Buffer will hold a line of text now and the while encapsulation of the getline will run getline on the whole file until end of file is reach.
  • Now with stringstream, you can feed the buffer string into the stringstream object using cin and cout functions. So either buffer>>ss or ss<<buffer.
  • The beauty of a stringstream object at this point is that it can parse out a line of text word by word. you'll want another string object at this point like called temp or something to feed each individual line of text to be manipulated. You do this with the cout function such as ss>>temp. This will put one word at a time in order into the temp variable. You'll erase the first character of the string, add it to the end, and then also add ay at the end. This needs to be some sort of loop so that it can feed each word of the line into temp until the ss object is completely through the line.
  • One last important thing. in the loop for get line, make sure to do ss.clear() before returning back to the top of the while(getline()) loop. This clears the stringstream buffer and allows it to be filled with new text. Otherwise it will only change one word and it will be stuck

Thats about as much as I'm willing to do for you without doing the work for you. Hopefully this helps and I recommend using stackoverflow and the official c++ website as much as possible.

cplusplus.com - The C++ Resources Network
Stack Overflow
 

K.Dot

African American
Joined
Apr 19, 2015
Messages
14,306
Reputation
5,521
Daps
41,370
Reppin
Bro 'nem
fukk C++:ahh::umad:. The performance ain't worth the headache and dealing with garbage collection isn't that bad IMO.
 
Top