Click here to Skip to main content
15,897,518 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: 16x16 Pin
15-May-02 6:34
suss15-May-02 6:34 
GeneralString error again! Help plz Pin
tongc15-May-02 4:39
tongc15-May-02 4:39 
GeneralRe: String error again! Help plz Pin
tongc15-May-02 5:07
tongc15-May-02 5:07 
GeneralRe: String error again! Help plz Pin
tongc15-May-02 6:23
tongc15-May-02 6:23 
GeneralRe: String error again! Help plz Pin
Jonathan Craig15-May-02 7:24
Jonathan Craig15-May-02 7:24 
GeneralRe: String error again! Help plz Pin
Joaquín M López Muñoz15-May-02 5:21
Joaquín M López Muñoz15-May-02 5:21 
GeneralRe: String error again! Help plz Pin
tongc15-May-02 6:21
tongc15-May-02 6:21 
GeneralMemory compareing with char's Pin
SilverShalkin15-May-02 4:07
SilverShalkin15-May-02 4:07 
ok... this shouldnt be a hard question to answer, but knowing my luck... Smile | :)
i have a pointer in my header called:

char *M_Name;

The problem accures in this function: I want to Set the name that you enter in, then have that info stored in an array... in this case the array is

char Names[21];// for 20 names.

bool Name::SetName(char* NName)
{

if(!NName)//checking input
{
return false;
}

int NLen = (strlen(NName) + 1);
char *NewName = new char[NLen];

if(!NewName)//checking if allocation faild or not
{
return false;
}

strcpy(NewName, NName);
delete[] M_Name;
M_Name = NewName;

Names[NN] = *M_Name;
NN++;

return true;
}

when it gets to M_Name = NewName, it sets the name you entered into the pointer. Then i wanted to store that same name into the array "stating at 0" so i put in:

Names[NN] = *M_Name; //then i increase NN by one to change the memory slot.

the only problem is... when i try to print this info... i only get the first character of whatever name i insert.

im not to sure on why... i think i need to make each of the data 0-19 have an amount of memory attached to them, is this the right code to insert:

char Names[21][32];?

and if that is the right code to insert, how would i set M_Name to = to 32 bytes of memory without declaring:

char *M_Name[32];

?

Thanks for the help!

~SilverShalkin


GeneralRe: Memory compareing with char's Pin
Jason Henderson15-May-02 4:41
Jason Henderson15-May-02 4:41 
GeneralRe: Memory compareing with char's Pin
SilverShalkin15-May-02 4:55
SilverShalkin15-May-02 4:55 
GeneralRe: Memory compareing with char's Pin
SilverShalkin15-May-02 5:02
SilverShalkin15-May-02 5:02 
GeneralRe: Memory compareing with char's Pin
Jason Henderson15-May-02 5:20
Jason Henderson15-May-02 5:20 
GeneralRe: Memory compareing with char's Pin
Jason Henderson15-May-02 5:22
Jason Henderson15-May-02 5:22 
GeneralRe: Memory compareing with char's Pin
Joaquín M López Muñoz15-May-02 5:24
Joaquín M López Muñoz15-May-02 5:24 
GeneralRe: Memory compareing with char's Pin
SilverShalkin15-May-02 8:29
SilverShalkin15-May-02 8:29 
GeneralRe: Memory compareing with char's Pin
Joaquín M López Muñoz15-May-02 9:03
Joaquín M López Muñoz15-May-02 9:03 
GeneralProb. to catch the EOF ?! Pin
Fred D.15-May-02 4:02
Fred D.15-May-02 4:02 
GeneralRe: Prob. to catch the EOF ?! Pin
Jeremy Falcon15-May-02 5:22
professionalJeremy Falcon15-May-02 5:22 
GeneralRe: Prob. to catch the EOF ?! Pin
Joaquín M López Muñoz15-May-02 5:17
Joaquín M López Muñoz15-May-02 5:17 
GeneralMultithreading in C++ without MFC Pin
15-May-02 3:19
suss15-May-02 3:19 
GeneralRe: Multithreading in C++ without MFC Pin
Prem Kumar15-May-02 3:45
Prem Kumar15-May-02 3:45 
GeneralRe: Multithreading in C++ without MFC Pin
Nish Nishant15-May-02 3:51
sitebuilderNish Nishant15-May-02 3:51 
GeneralRe: Multithreading in C++ without MFC Pin
Tim Smith15-May-02 4:45
Tim Smith15-May-02 4:45 
QuestionHow can I get and set the keyboard state? Pin
Edwin Geng15-May-02 2:11
Edwin Geng15-May-02 2:11 
AnswerRe: How can I get and set the keyboard state? Pin
Chris Losinger15-May-02 6:46
professionalChris Losinger15-May-02 6:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.