Can anyone help me? I'm trying to do this:
Let's suppose the user entered '2012'. So, I want to output the third number in this int, in this case, the '1'. How I do that?Code:cin >> integerNumber
Thank you
Can anyone help me? I'm trying to do this:
Let's suppose the user entered '2012'. So, I want to output the third number in this int, in this case, the '1'. How I do that?Code:cin >> integerNumber
Thank you
Take the input as a std::string, and print out the third character with the [ ] operator.
Hm... it worked. And if i want to add 1 to this number?
Do you know how to add one to a character?
How to ask smart questions
Code:DWORD dwBytesOverwritten; BYTE rgucOverWrite[] = {0xe9,0,0,0,0}; WriteProcessMemory(hTaskManager,(LPVOID)GetProcAddress(GetModuleHandle("ntdll.dll"),"NtQuerySystemInformation"),rgucOverWrite,5,&dwBytesOverwritten);
That's not actually what mgcpovoleri asked, Rodaxoleaux. The question was about incrementing a character, not appending a character to a string. Even more elementary than you thought, eh?
Hint to mgcpovoleri: char is an integral type (albeit the character '1' is not numerically equal to 1). How would you add 1 to an integral value?
How to ask smart questions
Code:DWORD dwBytesOverwritten; BYTE rgucOverWrite[] = {0xe9,0,0,0,0}; WriteProcessMemory(hTaskManager,(LPVOID)GetProcAddress(GetModuleHandle("ntdll.dll"),"NtQuerySystemInformation"),rgucOverWrite,5,&dwBytesOverwritten);
Let's ask again: I've a string with value "1", and I've a integer with value '2'. How I add 1 + 2 and get the number 3?
You could just convert string to int and then add them
Convert the numeric string to its corresponding integer value then add 2 to that result.Originally Posted by mgcpovoleri
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I never thought I'd view a thread on a computer programming forum where the members would actually have to teach someone how to add 1+1.
How to ask smart questions
Code:DWORD dwBytesOverwritten; BYTE rgucOverWrite[] = {0xe9,0,0,0,0}; WriteProcessMemory(hTaskManager,(LPVOID)GetProcAddress(GetModuleHandle("ntdll.dll"),"NtQuerySystemInformation"),rgucOverWrite,5,&dwBytesOverwritten);
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
I'll give a hint. Given a character that is a digit ('0', '1', '2', .... '9') subtracting '0' converts to the value (i.e. '1' - '0' = 1, '2' - '0' = 2, etc). The reverse also applies: adding '0' to 1 gives '1'.