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

C / C++ / MFC

 
GeneralRe: CStdioFile Question... Pin
Nish Nishant14-May-02 17:17
sitebuilderNish Nishant14-May-02 17:17 
GeneralRe: CStdioFile Question... Pin
Emearg14-May-02 18:05
Emearg14-May-02 18:05 
GeneralA good tool for programmer Pin
14-May-02 15:35
suss14-May-02 15:35 
GeneralCreating UI with Threads Pin
Coremn14-May-02 15:23
Coremn14-May-02 15:23 
GeneralRe: Creating UI with Threads Pin
Tim Smith14-May-02 15:35
Tim Smith14-May-02 15:35 
GeneralRe: Creating UI with Threads Pin
Coremn14-May-02 15:48
Coremn14-May-02 15:48 
GeneralRe: Creating UI with Threads Pin
Jon Hulatt15-May-02 0:07
Jon Hulatt15-May-02 0:07 
GeneralUnhandled exception... Pin
SilverShalkin14-May-02 14:49
SilverShalkin14-May-02 14:49 
ok... I've had problems with unhandled exception error before... but right when i fixed it, i kind of forgot what i did to fix it... this is my code... "im posting it all.. except my header file, just to make sure you know what im doing."

#include <iostream>
#include "Class.h"//included header "Class.h"

using namespace std;

Name person; //class def person

int NN = 1;//incriment
char Names[21]; //total amount of names

char SName[100];

//SetName function.
bool Name::SetName(char* NName)
{

if(!NName)
{
return false;
}

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

if(!NewName)
{
return false;
}

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

Names[NN] = *M_Name;//I think it has somthing to do with this
NN++;

return true;
}

const char* Name::GetName()
{
return M_Name;
}


//main
int main()
{
for(;;)//main loop
{
gets(SName);
person.SetName(SName);
cout << person.GetName() << endl << endl; //print name that you just typed.

for(int inc;inc < NN;inc++) //print all names.
{
cout << Names[inc] << endl; //error unhandled exception.
}//end of print all names, loop.

inc = 1;
}//end main loop.

return 0;
}
//end main




//constructor & deconstructor
//*******************
Name::Name()
{
M_Name = NULL;
}

Name::~Name()
{
delete[] M_Name;
}

The error accured when i tried to set Names[NN] = *M_Name; the error feels like its at the tip of my tongue, yet i cant think of it.

Thanks all for the help!

~SilverShalkin

ps... how do you show a screen shot of your code? or post your code on CP with its background different... "is ther a place on the forum that shows how?"
Thanks!

Rose | [Rose]
GeneralRe: Unhandled exception... Pin
soptest14-May-02 15:00
soptest14-May-02 15:00 
GeneralRe: Unhandled exception... Pin
Christian Graus14-May-02 15:08
protectorChristian Graus14-May-02 15:08 
GeneralRe: Unhandled exception... Pin
Christian Graus14-May-02 15:06
protectorChristian Graus14-May-02 15:06 
GeneralRe: Unhandled exception... Pin
SilverShalkin14-May-02 17:04
SilverShalkin14-May-02 17:04 
GeneralRe: Unhandled exception... Pin
Christian Graus14-May-02 17:36
protectorChristian Graus14-May-02 17:36 
GeneralRe: Unhandled exception... Pin
SilverShalkin14-May-02 18:01
SilverShalkin14-May-02 18:01 
GeneralRe: Unhandled exception... Pin
Christian Graus14-May-02 18:47
protectorChristian Graus14-May-02 18:47 
GeneralRe: Unhandled exception... Pin
Renjith Ramachandran14-May-02 18:05
Renjith Ramachandran14-May-02 18:05 
GeneralRe: Unhandled exception... Pin
SilverShalkin15-May-02 3:44
SilverShalkin15-May-02 3:44 
GeneralDrawing Image For The Web Pin
Nick Parker14-May-02 14:29
protectorNick Parker14-May-02 14:29 
GeneralSort algorithm Pin
John Cruz14-May-02 12:45
John Cruz14-May-02 12:45 
GeneralRe: Sort algorithm Pin
Christian Graus14-May-02 12:51
protectorChristian Graus14-May-02 12:51 
GeneralRe: Sort algorithm Pin
John Cruz14-May-02 13:00
John Cruz14-May-02 13:00 
GeneralRe: Sort algorithm Pin
Christian Graus14-May-02 13:02
protectorChristian Graus14-May-02 13:02 
GeneralRe: Sort algorithm Pin
John Cruz14-May-02 13:15
John Cruz14-May-02 13:15 
GeneralRe: Sort algorithm Pin
Christian Graus14-May-02 13:48
protectorChristian Graus14-May-02 13:48 
GeneralRe: Sort algorithm Pin
John Cruz14-May-02 14:23
John Cruz14-May-02 14:23 

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.