C Cheat Sheet
by blfrj via cheatography.com/73472/cs/18520/
Libs (#include) Strings Reservar Memoria
<stdio.h> fgets( str, size, stdin) int** reservaMemoria(int filas, int
<stdlib.h> strlen( str) columnas) {
int ** matriz, i=0;
<string.h> strlcpy( dest, src, size)
matriz = (int**) malloc(filas *
<math.h> strcmp( str1, str2) (M < m)
sizeof (int*));
<unistd.h> - sleep()
> 0 str1 > str2 for (i = 0; i < filas; i++){
= 0 str1 = str2 matriz[i] = (int*)
I/O
= 0 str1 = str2 malloc(columnas * sizeof (int));
FLUSH IN __fpurge(stdin) }
end: "\0"
FLUSH OUT fflush(stdout) return(matriz);
IN scanf("formato", &var) Pointers
}
OUT printf("string")
declaration int *ip;
Liberar Memoria
storing address ip = &var;
Data void liberaMemoria(int**matriz, int
ip bffd8b3c filas){
(un)signed char %c
*ip var (value) int i=0;
short %hi
for(i=0;i<filas;i++){
unsigned short %hu Files free(matriz[i]);
int %i / %d }
FILE *pointer
unsigned int %u pointer = fopen ("files", "mode")
free(matriz);
long %li }
fread(point(O), sizeof(varType), 1, point(I))
float %f fwrite(point(I), sizeof(varType), 1, point(O))
Reservar struct
pointer addr %p
fseek( pointer, size, whence: )
struct struct_files *arrayFiles;
string %s S EEK_SET Inicio void reservarStruct(int
S EEK_CUR Pos actual nElementos, struct struct_files*
Format
S EEK_END Final arrayFiles){
%0.n f n decimales
fclose(pointer)
%nd Tamaño (espacios pre) arrayFiles = (struct
%0nd Tamaño (0 pre) struct_files*)
File Open: mode - operation - exist
malloc( sizeof (struct
r read N: NULL
Char Array -> String struct_files) * nElementos);
w write Y: overw N: create }
void qs(char *cad){
a append N: create
if (cad[strlen(cad)-
r+ read/write N: NULL Liberar struct
1]=='\n'){
cad[strlen(cad)-1]='\0'; w+ read/write Y: overw N: create void liberarStruct(struct
} struct_files* arrayFiles){
a+ read/app N: create
}
Mb binary
free(arrayFiles);
}
By blfrj Not published yet. Sponsored by Readability-Score.com
cheatography.com/blfrj/ Last updated 17th January, 2019. Measure your website readability!
Page 1 of 2. https://readability-score.com
C Cheat Sheet
by blfrj via cheatography.com/73472/cs/18520/
Open Carefully
if((salida = fopen("files.dat", "r+")) ==
NULL){
salida =
fopen("files.dat","w+");
}
By blfrj Not published yet. Sponsored by Readability-Score.com
cheatography.com/blfrj/ Last updated 17th January, 2019. Measure your website readability!
Page 2 of 2. https://readability-score.com