• Welcome to Valhalla Legends Archive.
 

Header Symbol

Started by ChroniX, January 16, 2007, 11:14 PM

Previous topic - Next topic

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

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

warz

they're called preprocessor directives, here's a quality hyper link: http://www.cplusplus.com/doc/tutorial/preprocessor.html

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...

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.

ChroniX

Also, I have heard you can only use the cout function when using <iostream>. Is this true?

DeTaiLs

Yes it is true, read this it tells you some of the functions for each libary
http://www.cplusplus.com/reference/iostream/



MyndFyre

Quote from: ChroniX on January 18, 2007, 03:34 PM
Also, I have heard you can only use the cout function when using <iostream>. Is this true?

cout isn't actually a function, it's an object.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

ChroniX

Well Mynd, thank you very much for pointing that out.  :P

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)

#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();
}

K


cout >> numer;


you can't get input from cout.


cin >> number;

ChroniX

Ah okay, that's it! Thank you very much for your help.  :)

ChroniX

#12
What is wrong with this code? It will compile but wont execute.

#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();
}

Warrior

Why don't you use a little debugging (either with breakpoints in VS or simply by printing out the value of input)
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?