0

Hi,
I am trying to convert a char pointer to a normal char(somehow copy the strings from the pointer and pass it to the char)

Here is a piece of example on what i want to do

#include <iostream>
#include <windows.h>
using namespace std;

int main()
{
    char *namen="Test";
   char test[255];

    test=namen;
    cout<<test<<endl;

    return 0;
}

If i run that code i get the following error : "invalid conversion from char** to char"

I know you cant just copy a char pointer to a char but is there a way or a technique to do it?
Thanks in advanced.

Edited by Martje: n/a

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by WaltP
0

Ok i replaced it to something better, but is it possible to do what i want to do?

0

You actually did it in reverse.

int main()
{
    char *namen;
   char test[255] = "Test";

    namen = test;
    cout << test << endl;
    cout << namen << endl;

    return 0;
}

The pointer can receive the address of the array. Not the other way around.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.