I'm trying to make a program that loops through all of the characters in a string and replace each one with a corresponding alteration of the character. How should I start going about this without creating a rule for each separate letter?
ie. cin cout >> "_B__I__G_ _D__O__G__S_"
Carter Perry
/dpt/ /sqt/
Jordan Ward
iterate though your list of chars, uppercasing and adding a _ before/after it.
Oliver Scott
is this a shitpost?
Jaxon Cruz
def munge s '_' + s.upcase.chars.join('__') + '_' end
'___'
Grayson Hall
how would I append that through the iteration? are there any chapter in a C++ textbook I should look at for the relevant expressions?
Ayden Anderson
Are you mentally retarded or just a fucking idiot?
Wyatt Torres
google search yielded nothing
Zachary Sanchez
getting expression must have class type on s
Brandon Allen
what does this even mean?
Brayden Brooks
well.. if you don't have a dynamic array/list, you'll have to create another one (since you'll be altering it's size) and for each char read, you put: an underscore, the uppercased char, another underscore, and then just jump 3 units instead of one in the for loop, i guess. if your array is dynamic there are perhaps better ways of doing it. there are always better ways of doing anything on cs.
Samuel Gomez
cin >> words; int size = words.size(); for (words; i = 0; i < size) ++i; { while (i < size); { ":regional_indicator_" + words + ':'; }
}
cout
Christian Roberts
Should I encapsulate something in a function? I'm very lost here and obviously have had no formal education in this. Could anyone point me to any resources that explain this better?
Austin Reyes
>for (words; i = 0; i < size) ++i; shouldn't it be for (words; i = 0; i < size; ++i) ?
Jackson Young
>how do I loop through a string
for fucks sake this is extremely low quality bait or you are retarded
Gavin Cook
It should be, but it tells me it is expecing ) after size;
Grayson Scott
oh my bad, it should be like this: for (int i = 0; i < size; ++i) { i totally ignored the first section of the for loop
Brayden Hall
sorry I wasn't born knowing C++ fluently. I'll try to get born better next time.
Aaron Bennett
also, if you really want/need to learn, try getting Lipmann's C++ Primer or just get any book at http:// programming-motherfucker . com / (it's a real site, i'm not joking lol)
Luke King
Oh, yeah that worked. Thanks.
Aiden Adams
Try to get aborted next time, you dumb fucking shit stain.
Liam Smith
I'll pirate whatever I can from the motherfuckers site tonight and start reading tomorrow. I was hoping I could finish this tonight, but there's no way.
Noah Phillips
if you worked up over something so trivial, your life must suck dude. i kinda feel sorry for you.
Gavin Walker
their books are all free :^) if you want to pirate something, go for lipmann's book, although i think you should learn C before C++ but who am i to say anything right?
Landon Sanders
Create a map where the keys are letters and the values are arrays of "alteration" characters.
As you iterate over the string, index the map with each character, generate a random number between 0 and array.size() -1, and retrieve the character at that index in the array. Then set string character to be equal to the character you just retrieved.
Luis James
Really? Is C sharp lower level than C++?
Luke Allen
No, but C is. besides Assembly, C will be the lowest level language one would use.
Ayden Cox
Anyway, I gotta go. if you want to learn C (what I think you should do before C++) try searching for K&R C Book, it's the start of C, everyone should at least once at it imo. also, pic of my book :^) see ya
Robert Wilson
Thanks a lot guy, I'll check it out!
Tyler Watson
Is there meant to be a space between the words? On mobile so can't tell.
Juan Brooks
The C way: Make new storage location Create counter at 0 For every character in input copy over _, char, _... Incrementing counter each time
//Java way String input = "bdog"; String output = ""; For(int i = 0; i < input.length(); i++) { Output += ('_' + input.charAt(i) + '_');
I'm on the toilet so this might not be syntactically correct