Thread: alternate to

  1. #1
    Registered User
    Join Date
    Aug 2001

    alternate to

    I was having an error, the ilLoadImage function wont take a const char*, only a char*, so i fixed it like this. Is there another way to do it? I removed all the other stuff from the funtion so you can read it easily.

    unsigned int cRenderEngine::LoadTexture(string path, short size) {
    	char * temp = new char[path.length()];
    	for(int i = 0; i < path.length(); i++)
    		temp[i] = path[i];	

  2. #2
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Use strcpy in <cstdlib>
    char* temp = new char[path.length() + 1];
    strcpy(temp, path.c_str());
    delete [] temp;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. alternate to an array???
    By Loic in forum C++ Programming
    Replies: 21
    Last Post: 07-08-2008, 08:59 PM
  2. alternate to string streams
    By MicroFiend in forum C++ Programming
    Replies: 9
    Last Post: 04-30-2008, 02:03 AM
  3. Alternate energy sources
    By Govtcheez in forum A Brief History of
    Replies: 10
    Last Post: 02-02-2005, 07:07 PM
  4. read from alternate file on PC
    By brooklyn1126 in forum C++ Programming
    Replies: 1
    Last Post: 05-15-2004, 10:30 PM
  5. alternate function to sprintf
    By Eber Kain in forum C++ Programming
    Replies: 5
    Last Post: 12-27-2002, 10:38 PM