Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having Pointer problem :/

Status
Not open for further replies.

Parkinmike

Programmer
Apr 16, 2005
1
GB
Hi having a problem with some c++ I hope someone can help me becuase i need to get this sorted in my head quickly!

Basically I have a function, inside a public class that opens a wav file. then i have a main function which calls the function (and sends music.wav)

this is the code:

Code:
Public:
       bool openWavfile(char* fileName)
       {
       //**does some stuff here**//
       }
 
 

};


(void) main (void)
{ 
      w.openWavfile("C:\\music.wav");
}

I am confused when i get to the line "bool openWavfile(char* fileName)"

From what i understand: this is a function called openWavefile, it returns bool type data.
It has an argument (char*fileName) and the argument is a pointer.

what i would like to know is: how does the pointer work? i guess that it doesnt give char fileName the value of c:\\music.wav.
Does it assign the the address in memory of C:\\music.wav or is it just a decleration of a pointer?
Im really stuck on this, its baffling me!

if you could either post here, or add me to MSN Parkin_m@hotmail.com if you dont mind having a quick chat with me...

PLease be quick!

Thanks

Michael
 
1. Better use const char* fileName declaration.
2. String literals "..." have a type of pointer to const char array in C++. They represent arrays of char initialized by char sequence between quotes plus zero byte terminator.
3. Array names in C/C++ are treated as a (may be const) pointers to char in all contexts except sizeof operator arg.
4. In old C string literals were not a const objects. So many compilers don't report errors when string literals passed to non-const argument.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top