Well, what i'm trying to do is use cin.getline with my char pointer of 255 characters, take a look at the code below:

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <conio.h>

using namespace std;

char * pChar[255];
pChar = new char[255];

void newPointer()
    {
                 delete pChar;
                 pChar = new char[255];
    }
                 

int main(int argc, char *argv[])
{
    cout << "Enter a line of text: ";
    cin.getline(pChar, 255);
    void newPointer();
    
    cout << "Enter another line of text: ";
    cin.getline(pChar, 255);
    delete pChar;
    
    cin.get();
    return EXIT_SUCCESS;
}

Am I doing something wrong or what? If you want I can copy and paste the error codes I get from it, they're confusing. Thanks, I appreciate all the help I can get.
=D

for this part of code

char * pChar[255];
pChar = new char[255];

you do not want to declare pchar with its elements. you save that for the new operator part. so you would want to do this

char * pChar;
pChar = new char[255];

also when you delete an array you always want to place the array operator before the name of the array. otherwise you will just delete the head of the array but the rest of it will still be sitting there in memory taking up resources until your application exits.
make sure you alway use delete [] variable_name; also it is always a good idea to set your pointer to null after deleting it. deleting a pointer that has already been deleted is guaranteed to crash your system but deleting a null pointer is safe.

Member Avatar for jencas
...
int main(int argc, char *argv[])
{
    ....
    void newPointer(); // that's NOT a function call!!!
    ...    
}

I marked another problem with a comment!!!

Okay, thank you guys for helping me out, I appreciate it much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.