int main() { cin >> words; output = ""; int size = words.size(); for (i = 0; i < size; ++i); { while (i < size); { output += (":regional_indicator_" + words.at[i] +':'); } }
cout
John Stewart
never mind the cout at the end, I already fixed that to output.
Bentley Collins
the error is on the line output += ... and pertains to words.at[i] I presume
Luke Thomas
Wow, that's embarrassing
Noah Watson
>isn't a string inherently an array of characters
Yes, but C++ (correctly) tries to hide this from you. Something like words.c_str()[i] might work.
Thomas Price
It runs with that but it doesn't print anything
Kayden Peterson
Yes but a function is not an array of characters.
Isaiah Myers
and debugging didn't give me any valuable insight
Tyler Ramirez
Probably because you're exiting your for and while loops immediately by putting a semicolon before the loop body
Andrew Bennett
Explain to us exactly what your code is doing here (hint: your error is there): for (i = 0; i < size; ++i); { while (i < size); { output += (":regional_indicator_" + words.at[i] +':'); } }
Oliver Morris
words.at is a function. You're trying to index a fucking function. words[i] //or alternatively words.at(i)
Your fucking loops end with a semicolon; for (i = 0; i < size; ++i)/*----->*/; // */; //
Benjamin Ross
Only two anons have stated the blatant problem of this code, fuck neo-Sup Forums.
Alexander Ross
Thanks. I took out the trouble semi colons. Now when the program is ran and text is entered, it creates a new line and does not close. After a minute it's using 356 MB of my memory...
Christopher Lopez
and sadly this isn't bait. this is the extent of my coding prowess from what I can remember of the programming class I took 4 years ago.
Owen Perry
what do you think this does: while (i < size) { output += (":regional_indicator_" + words.at[i] +':'); }
Hudson Roberts
#include "stdafx.h" #include #include #include using namespace std;
string output; string words; int i;
int main() { cin >> words; output = ""; int size = words.size(); for (i = 0; i < size; ++i) { while (i < size) { output += (":regional_indicator_" + words.c_str()[i] +':'); } }
cout
William Mitchell
That is some spaghetti code.
From what I'm seeing you need to take a step back and start at square one, user. Relearn for and while loops and how they're structured.
Leo Gutierrez
adds each character in a string to output plus the string of text and char.
Jacob Murphy
Yeah, the second line does the concatenation as you say. But what about the first and last lines, do you really need this block surrounding it? If yes, why?
Brayden Green
The while loop will run forever as there is no chance for the i to get an increasement. Remove it
Thomas Jackson
This
Ryan Wright
This is a sad thread
Alexander Hall
If as I think you want to display each word of your input with a prefix, you should rather the standard 'std::split' method to get a word array, then use a loop (use a standard iterator if you feel brave enough)
Brandon Cooper
negative, each letter.
Angel Bennett
#include "stdafx.h" #include #include #include using namespace std;
string output; string words; int i;
int main() { cin >> words; // gets words from user output = ""; // readys the output string i = 0; // warms up the calculator int size = words.size(); // size matters while (i
John Collins
Get rid of the while loop (also the while loop has nothing inside of it because of your ; If you want to get the character that the i position of words just do words[i].
Brandon Barnes
I took the ; out of the while loop function and added && + i to the code of the loop. Now the console gives me hello world [6 blank square characters] Press any key to continue . . .
Ayden Young
>stray semicolon strikes again
OH MY GOD
Levi Morgan
I count 3 before you and two more calling OP an idiot.
Luke Thompson
#include "stdafx.h" #include #include #include using namespace std;
string output; string words; int i;
int main() { cin >> words; // gets words from user output = ""; // readys the output string i = 0; // warms up the calculator int size = words.size(); // size matters while (i
Eli Ramirez
did I accidentally create a new open-source encryption algorithm?
Adam Hill
what the fuck are you even trying to accomplish with that nested loop ?
Isaiah Jenkins
IF this isn't bait, just quit now. There is no hope for you, if you are this unaware or stupid.
Jack Ramirez
it seems a lot of people here were born knowing C++ syntax. What is your nationality?