G
Guest
I have a Microsoft C/C++ compiler version 12.00.8168 installed on my PC
running Windows 2000.
I have no problem to use the MS C/C++ compiler to compile the following 'C'
program and get an executable.
*********************************
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
void initstr(char* istr, int len);
void testcat();
int main(int argc, char** argv) {
testcat();
return 0;
}
void testcat() {
int i=0,j=67;
char f11[13];
char recordIdentity[100];
for (i=0; i<j; i++) {
if (i==10) {
printf("i=%d, j=%d\n",i,j);
strcpy(f11,"1234567890ab");
strcpy(recordIdentity,"<urwg:TimeInstant urwg:type=\"queue\">");
strcat(recordIdentity,f11);
strcat(recordIdentity,"</urwg:TimeInstant>\n");
printf("before string concatenation: j=%d\n",j);
strcat(recordIdentity,"<urwg:TimeInstant urwg:type=\"ready\">");
strcat(recordIdentity,f11);
printf("after string concatenation: j=%d\n",j);
strcat(recordIdentity,"</urwg:TimeInstant>");
}
}
printf("j=%d\n",j);
}
*********************************
But when I run the executable, I get the following incorrect output and
the executable crashes.
Outputs:
****************
i=10, j=67
before string concatenation: j=67
after string concatenation: j=1042446692
j=1042446692
Any ideas?
Thanks for your attention.
Richard
running Windows 2000.
I have no problem to use the MS C/C++ compiler to compile the following 'C'
program and get an executable.
*********************************
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
void initstr(char* istr, int len);
void testcat();
int main(int argc, char** argv) {
testcat();
return 0;
}
void testcat() {
int i=0,j=67;
char f11[13];
char recordIdentity[100];
for (i=0; i<j; i++) {
if (i==10) {
printf("i=%d, j=%d\n",i,j);
strcpy(f11,"1234567890ab");
strcpy(recordIdentity,"<urwg:TimeInstant urwg:type=\"queue\">");
strcat(recordIdentity,f11);
strcat(recordIdentity,"</urwg:TimeInstant>\n");
printf("before string concatenation: j=%d\n",j);
strcat(recordIdentity,"<urwg:TimeInstant urwg:type=\"ready\">");
strcat(recordIdentity,f11);
printf("after string concatenation: j=%d\n",j);
strcat(recordIdentity,"</urwg:TimeInstant>");
}
}
printf("j=%d\n",j);
}
*********************************
But when I run the executable, I get the following incorrect output and
the executable crashes.
Outputs:
****************
i=10, j=67
before string concatenation: j=67
after string concatenation: j=1042446692
j=1042446692
Any ideas?
Thanks for your attention.
Richard