The low-level mistakes that appear in these two days [April 18, 2004]

zhaozj2021-02-16  61

1. Programming in C

Put the variable in the middle of the execution statement, there is an inexplicable error

Such as:

Int a;

Printf ("% d / n", a);

INT B;

C learned from home, I didn't think it was wrong for several days.

2. Ansistring, CSTRING defined in structures

TYPEDEF STRUCT TAGTMP {ANSISTRING STR1; ANSISTRING STR2;} TMP

TMP * P = New TMP [10]; delete [] p; Is there an error above? An error occurred after each run. Just started under the BCB, you don't prompt every time. Under the VC, use Delete [] P error. I have been saying that CString is unstable, maybe this may be asnistring, cstring is not '/ 0' ending and unregistered, so delete's space, it is not accurately Error happened.

Replace

Typedef struct tagtmp {char str1 [10]; char str2 [20];

TMP * P = New TMP [10]; delete [] P;

problem solved

April 22, 2004

Really solved? In fact, it did not solve it. I sent a post in 9CBS and found that the element with cstring as a Struct was re-delete won't be wrong. How is this going? Think that it is also a class of C , delete is a destructive function that calls CString to clear, and should not have any problems. Now I want to go back to the wrong place. I can't go back, faint. In the BCB Ansistring as the element of Struct, the problem is still after all of the ANSISTRING is all set, and the problem is still. Delete the structural pointer, there is an inexplicable error. what happened

July 11, 2007

Later, I thought of a possible error: After the new structure, I usually use MEMSET to clear, and the initialization information of these objects, the initialization information of these objects is also removed, so the boundaries of the string are unclear, naturally mistaken

转载请注明原文地址:https://www.9cbs.com/read-17206.html

New Post(0)