Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Debugger Exception Notification

Status
Not open for further replies.

qiqinuinaifen128

Programmer
Dec 9, 2007
20
SG
Hi there,

Below is my code, when i run it it show this error" Debugger Exception Notification" can anyone give me suggestion. Thank You.

Code:
#pragma hdrstop
#pragma argsused
#include <stdio.h>
#include <conio.h>
#include "string.h"
char **word;
int i;

void add( char *newWord )
{

   word[ i ] = new char[ strlen( newWord ) + 1 ];
   strcpy( word[ i ], newWord );
}
void main(int argc, char* argv[])
{
   add("MoveForward");
}

Singapore Swimming Lessons
 
[tt]word[/tt] itself needs to be initialised before you start doing stuff with [tt]word[/tt]

Eg.
[tt]word = new char*[10];[/tt]




--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
Thank you! Solve it already
Code:
#pragma hdrstop
#pragma argsused
#include <stdio.h>
#include <conio.h>
#include "string.h"
char **word;
int i;

void add( char *newWord )
{


   word = new char*[10];
   word[ 1 ] = new char[ strlen( newWord ) + 1 ];
   strcpy( word[ 1 ], newWord );

}
void main(int argc, char* argv[])
{
   add("MoveForward");
   printf("%s", word[1]);
   getch();
}

i have one thing not understand is when i want to print the word[1], i need to use %s not %c. When i declare word is using char...

Singapore Swimming Lessons
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top