| View previous topic :: View next topic |
| Author |
Message |
Blazin Grandmaster Cheater
Reputation: 0
Joined: 17 Sep 2006 Posts: 770 Location: Somewhere over the rainbow.
|
Posted: Sat May 10, 2008 7:50 pm Post subject: Subscript 2 in C++? |
|
|
| IS it possible to make a subscript 2 in C++?
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sat May 10, 2008 9:32 pm Post subject: |
|
|
You mean this ² ??
_________________
|
|
| Back to top |
|
 |
Blazin Grandmaster Cheater
Reputation: 0
Joined: 17 Sep 2006 Posts: 770 Location: Somewhere over the rainbow.
|
Posted: Sat May 10, 2008 10:00 pm Post subject: |
|
|
| lurc wrote: | | You mean this ² ?? |
Yes.
|
|
| Back to top |
|
 |
HalfPrime Grandmaster Cheater
Reputation: 0
Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
|
Posted: Sat May 10, 2008 10:18 pm Post subject: |
|
|
That's a superscript...
And do you mean in the command prompt or in code or something?
_________________
|
|
| Back to top |
|
 |
Estx Expert Cheater
Reputation: 0
Joined: 04 Mar 2008 Posts: 172
|
Posted: Sun May 11, 2008 6:22 am Post subject: |
|
|
| The Unicode character byte for Superscript Two is 0xB2 (178).
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sun May 11, 2008 10:32 am Post subject: |
|
|
or just actually put the charecter in the string... >_>
Hold Alt and press 0178 on your numpad then let go of alt and the superscript 2 will pop up.
_________________
|
|
| Back to top |
|
 |
Blazin Grandmaster Cheater
Reputation: 0
Joined: 17 Sep 2006 Posts: 770 Location: Somewhere over the rainbow.
|
Posted: Sun May 11, 2008 10:38 am Post subject: |
|
|
| lurc wrote: | or just actually put the charecter in the string... >_>
Hold Alt and press 0178 on your numpad then let go of alt and the superscript 2 will pop up. |
Eh, well is there anyway to make a subscript? I don't really need a superscript
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sun May 11, 2008 10:42 am Post subject: |
|
|
₂ <-- that?
its unicode byte is 0x2082 (8322)
but thers no alt code for it so you'll have to copy and paste or set the charecters manually.
btw, Windows has this awesome program called Character Map.
It has most of your charecters all you have to do is look
_________________
|
|
| Back to top |
|
 |
Blazin Grandmaster Cheater
Reputation: 0
Joined: 17 Sep 2006 Posts: 770 Location: Somewhere over the rainbow.
|
Posted: Sun May 11, 2008 8:56 pm Post subject: |
|
|
| lurc wrote: | ₂ <-- that?
its unicode byte is 0x2082 (8322)
but thers no alt code for it so you'll have to copy and paste or set the charecters manually.
btw, Windows has this awesome program called Character Map.
It has most of your charecters all you have to do is look  |
When I try to paste it into Dev-C++, it comes up as v(2) and thats what it shows up as when i try to compile. Any ideas?
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sun May 11, 2008 9:01 pm Post subject: |
|
|
Switch to Visual Studio 2008 or Visual C++ Express 2008
I don't believe Dev-C++ uses UNICODE.
_________________
|
|
| Back to top |
|
 |
Blazin Grandmaster Cheater
Reputation: 0
Joined: 17 Sep 2006 Posts: 770 Location: Somewhere over the rainbow.
|
Posted: Sun May 11, 2008 9:22 pm Post subject: |
|
|
| lurc wrote: | Switch to Visual Studio 2008 or Visual C++ Express 2008
I don't believe Dev-C++ uses UNICODE. |
Edit: I'm going to use the switch command and make it multiple choice or something instead. However, I still want to learn what was wrong with my earlier code.
Ok, thanks for the advice. I will when I have some more time, but for now i need to finish a project for science thats due tomorrow lmao. I'm trying to compile this, and it works, but the if {} else {} thing isn't working for me. It keeps telling me correct, even if the coefficient is wrong.
| Code: | #include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
cout <<"Lets start with Synthesis reactions, I'll solve and then you will"
<<" balance it.\n\n"
<<"**NOTE**: You cannot make a subscript or superscript show up"
<<" in C++,\nlet alone command prompt. Therefore I will be using single"
<<" numbers in\nparenthesis as subscripts. "
<<"\n\nLets do Lithium + Oxygen. Li + O --> Li(2)O\n";
char nLiCo;
int nLi2 = 2;
cout << "What coefficient would go in front of Li on the reactant side?\n"
<<"If none, type none.";
cin >> nLiCo;
if ( nLiCo = 2)
{
cout <<"Correct!"
<< endl;
}
else
{
cout <<"Wrong!"
<< endl;
}
system("PAUSE");
return 0;
} |
Edit: I'm going to use the switch command and make it multiple choice or something instead. However, I still want to learn what was wrong with my earlier code.
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Mon May 12, 2008 8:00 am Post subject: |
|
|
your using an assignment operator in your if statement, not a conditional comparison.
= : Assignment
== : Equal
| Code: | if ( nLiCo == 2 )
{
}
else
{
} |
if you swich to VS2008/VC2008 Then you could do std::wcout or even better just use _tprintf and use UNICODE charecters so you could do
wcout:
| Code: | | std::wcout << _T("Subscript 2: ") << (TCHAR)0x2082; |
_tprintf:
| Code: | | _tprintf(_T("%c"),0x2082); |
Note:
1. Include tchar.h
2. _T( ) is a macro for UNICODE
_________________
|
|
| Back to top |
|
 |
Blazin Grandmaster Cheater
Reputation: 0
Joined: 17 Sep 2006 Posts: 770 Location: Somewhere over the rainbow.
|
Posted: Mon May 12, 2008 1:47 pm Post subject: |
|
|
Thanks a LOT!
+Rep, wonderful help.
|
|
| Back to top |
|
 |
|