What is char* ?
What is the * for in char* ??? Big time newb question but I dont want to assume.
char p; --> p is a character
char* p; --> p is a pointer to a character
A pointer is a variable that holds the address of another variable.
char p;
char* q;
q = &p
this causes the address of p to be assigned to q, causing q to ''point at'' p
Joshua Barczak3D Application Research GroupAMD
Noods:
char* x (or char *x for that matter) declares a pointer to a character.
John.
char* x (or char *x for that matter) declares a pointer to a character.
John.
when you see something like
char* Name
This is saying that the variable Name is a pointer of type char.
The * means the variable is a pointer.
char* is most often used to represent a string of undetermined size.
for example...
Hope this helps!
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
char* Name
This is saying that the variable Name is a pointer of type char.
The * means the variable is a pointer.
char* is most often used to represent a string of undetermined size.
for example...
#include <iostream>using namespace std;void main(){ char* test = "Hello, How are you?"; cout<<"The string is "<<test<<"."<<endl; cout<<"The third char in that string is "<<test[2]<<"."<<endl;}
Hope this helps!
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
WyrmSlayer RPG - In Early Development
Wow, that got a LOT of replies fast. 2 in the time that I typed mine =)
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
WyrmSlayer RPG - In Early Development
the ''*'' means it''s a pointer type
char* means that the variable is a pointer to a memory location that contains data of type char
search the internet for a C or C++ turorial and look up pointers
try: http://www.cplusplus.com/doc/tutorial/
when char* are used for character strings, they point to the first char in the string, the end of the string is marked by a null character ''\0''
you should really go over a couple tutorials, cause your right, it is a big time newb question
hope that helps
char* means that the variable is a pointer to a memory location that contains data of type char
search the internet for a C or C++ turorial and look up pointers
try: http://www.cplusplus.com/doc/tutorial/
when char* are used for character strings, they point to the first char in the string, the end of the string is marked by a null character ''\0''
you should really go over a couple tutorials, cause your right, it is a big time newb question
hope that helps
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement