1

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);

Edited by pyTony: fixed formating

2
Contributors
2
Replies
3
Views
12 Years
Discussion Span
Last Post by ok555
0

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.

0

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

This question has already been answered. 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.