요약: C언어에서 Char 마지막에는 널문자가 들어간다.

 

#include<string.h>  

// H,e,l,l,o,W,o,r,l,d,\0 -> size of 11
char original_string[] = "HelloWorld";

char destination_string[10];

// run tiem error: A combination of logically incorrect actions
strcpy(destination_string, original_string);
 

'Clanguage' 카테고리의 다른 글

Clanguage)How to check if a pointer is freed already in C?  (0) 2022.10.10
Clanguage) exit(0) VS exit(1)  (0) 2022.10.10
int* ptr = (int*)malloc(sizeof(int));
free(ptr);
ptr = NULL;

 

Ref) https://stackoverflow.com/questions/8300853/how-to-check-if-a-pointer-is-freed-already-in-c

'Clanguage' 카테고리의 다른 글

Clanguage) strcpy(destination_string, original_string);  (0) 2022.10.10
Clanguage) exit(0) VS exit(1)  (0) 2022.10.10

 

exit(0) // Exit_SUCCESS

 

exit(1) // Exit_FAILURE

+ Recent posts