Ok, im new to c++ and i looked around and couldn't find anything on it..
I have a global char such as the one below, i made a loop to go through and basically "grab" each name in the names list and then display it to me.. but instead of displaying the actual name, it shows some number (4210704).. anyone know how i can fix this? thanks

char *names[]={
    "test",
    "same",
};

I also get the same problem when trying to display text like the code below, i don't know what i'm doing wrong.. i get a number almost every time instead of the text in the char.. what am i doing wrong people?

char name[] = "bob";
char send[512];
sprintf(send, "testing this %d\n",name);

Recommended Answers

All 2 Replies

what am i doing wrong people?

char name[] = "bob";
char send[512];
sprintf(send, "testing this %d\n",name);

Use %s for strings; %d is for ints.

Your reply solved my problem, i didn't think there was a difference between the two (%s %d) but now i know there is. :)
Thanks

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.