Valhalla Legends Forums Archive | C/C++ Programming | Header Symbol

AuthorMessageTime
Chronix
Hello, I recently took up learning C++ in preparation for future game development (And sure do have plenty of time to learn since I don't attend school or have a job). I ran into something I'm not sure of that I am hoping somebody here could answer for me.

Does the # symbol in the header for "#include" stand as a sharp or a number? I assume sharp at the moment, but will revoke my thoughts until I get a correct answer.

Thanks,
  Brian
January 17, 2007, 5:14 AM
UserLoser
it's a precompiled header or directive.  tells the compiler to do something before compiling the code.  in this case, including a file full of probably definitions
January 17, 2007, 6:14 AM
warz
they're called preprocessor directives, here's a quality hyper link: http://www.cplusplus.com/doc/tutorial/preprocessor.html
January 17, 2007, 7:33 AM
shout
I might be a little off, but I think what you are asking is if the symbols used in C++ (like #, *, ->, ect.) have any ties to what the symbols would mean  if you were not using a programming langauge... I think.

The answer to that would be no. The '#' is just a non-alphanumeric symbol that happens to be used in pre-compiler directives. Some math symbols (+, -, ect) are common sense, adding by using the tilde would be confusing.

I think thats what you were asking... I'm not sure though...
January 18, 2007, 8:11 PM
Chronix
Sounds right on target to me!  ;)

I just never knew as to whether or not the symbol had any sort of name associated with it.

C++ is a great language to learn. I'm sure my time spent learning it will be well worth it. I know that Battle.net's population is slowly coming to an end, but I want to eventually write a bot for channel moderation.
January 18, 2007, 9:29 PM
Chronix
Also, I have heard you can only use the cout function when using <iostream>. Is this true?
January 18, 2007, 9:34 PM
Twix
Yes it is true, read this it tells you some of the functions for each libary
[url]http://www.cplusplus.com/reference/iostream/[/url]
January 18, 2007, 9:48 PM
Myndfyr
[quote author=ChroniX link=topic=16184.msg163347#msg163347 date=1169156076]
Also, I have heard you can only use the cout function when using <iostream>. Is this true?
[/quote]

cout isn't actually a function, it's an object.
January 18, 2007, 10:15 PM
Chronix
Well Mynd, thank you very much for pointing that out.  :P
January 18, 2007, 11:30 PM
Chronix
Well I'm having a problem here and hopefully somebody can help me. I get this error when trying to compile the code below

error C2784: 'std::basic_istream<_Elem,_Traits> & (Location of project on drive)

[code]#include <iostream>

using namespace std;

int main()
{
int number;

cout<<"Please enter a number: ";
cout>> number;
cin.ignore();
cout<<"You entered: "<< number <<"\n";
cin.get();
}[/code]
January 19, 2007, 1:21 AM
K
[code]
cout >> numer;
[/code]

you can't get input from cout.

[code]
cin >> number;
[/code]
January 19, 2007, 1:38 AM
Chronix
Ah okay, that's it! Thank you very much for your help.  :)
January 19, 2007, 1:49 AM
Chronix
What is wrong with this code? It will compile but wont execute.

[code]#include <iostream>

using namespace std;

void playgame();
void loadgame();
void playmultiplayer();

int main()
{
  int input;
 
  cout<<"1. Play game\n";
  cout<<"2. Load game\n";
  cout<<"3. Play multiplayer\n";
  cout<<"4. Exit\n";
  cout<<"Selection: ";
  cin>> input;
  switch ( input ) {
  case 1:
    playgame();
    break;
  case 2:
    loadgame();
    break;
  case 3:
    playmultiplayer();
    break;
  case 4:
    cout<<"Thank you for playing!\n";
    break;
  default:
    cout<<"Error, bad input, quitting\n";
    break;
  }
  cin.get();
}[/code]
January 20, 2007, 1:54 PM
Quarantine
Why don't you use a little debugging (either with breakpoints in VS or simply by printing out the value of input)
January 20, 2007, 5:48 PM

Search