Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

matdoz

Cancelled
Original poster
May 26, 2019
1
0
I'm new to programming, however I have not been able to find any answer googling for some hours now to my problem, and decided to try my luck here.

I am simply trying to assign some user input to a string using Xcode on a macbook writing in c++.

I am trying to make a calculator and for that to work I need it to be able to read '(' ')' parentheses from the user, however when I type in parentheses in the debugger terminal in Xcode (I believe its called that) I do not get the correct output/string variable assignment.

Any help would be greatly appreciated.

Tried using other datatypes such as wstring, char with no luck.


#include <string>

#include <iostream>

int main() {

std::string test = "";

while (std::cin >> test) {

std::cout << test << "\n";

}

return 0;

}


Input: 1+(2+2)
Output: 1+()2+2

Comment: The boxes displays some type of question mark symbols, looks like it won't show when pasted here though.
 
I'm new to programming, however I have not been able to find any answer googling for some hours now to my problem, and decided to try my luck here.

I am simply trying to assign some user input to a string using Xcode on a macbook writing in c++.

I am trying to make a calculator and for that to work I need it to be able to read '(' ')' parentheses from the user, however when I type in parentheses in the debugger terminal in Xcode (I believe its called that) I do not get the correct output/string variable assignment.

Any help would be greatly appreciated.

Tried using other datatypes such as wstring, char with no luck.


#include <string>

#include <iostream>

int main() {

std::string test = "";

while (std::cin >> test) {

std::cout << test << "\n";

}

return 0;

}


Input: 1+(2+2)
Output: 1+()2+2

Comment: The boxes displays some type of question mark symbols, looks like it won't show when pasted here though.

Works for me.

I am guessing you are having a unicode issue in your terminal program if you are seeing symbols.

Screen Shot 2019-06-04 at 8.44.31 PM.png
 
Rewrite the program so it outputs the hex value for every char or byte in the string it reads from cin.

This will at least show what the actual input data is.

It might also be helpful if you stated the OS and Xcode versions you're using. This can be important if someone wants to exactly replicate what you're doing.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.