0% found this document useful (0 votes)
24 views2 pages

C++ Clean Sheet

Uploaded by

aung sun lynn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

C++ Clean Sheet

Uploaded by

aung sun lynn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

C Cheat Sheet

by blfrj via cheatography.com/73472/cs/18520/

Libs (#include) Strings Reservar Memoria

<stdio.h> fget​s​( str, size, stdin) int** reservaMemoria(int filas, int

<stdlib.h> strl​en​( ​str) columnas) {


​ ​ ​ int ** matriz, i=0;
<string.h> strl​cpy​(​ dest, src, size)
​ ​ ​ ​matriz = (int**) malloc​(filas *
<math.h> strc​mp​( ​str1, str2) (M < m)
sizeof (int*));
<unistd.h> - sleep()
​ ​ ​ ​ ​ ​> 0 ​ ​ ​ ​str1 > str2 ​ ​ ​ for (i = 0; i < filas; i++){
​ ​ ​ ​ ​ = 0 ​ ​ ​ ​str1 = str2 ​ ​ ​ ​ ​ ​ ​ ​mat​riz[i] = (int*)
I/O
​ ​ ​ ​ ​ = 0 ​ ​ ​ ​str1 = str2 malloc​(co​lumnas * sizeof (int));
FLUSH IN __fpurge(stdin) ​ ​ ​ }
end: "​\0"
FLUSH OUT fflush(stdout) ​ ​ ​ ​ r​etu​rn​(m​atriz);

IN scanf("formato", &var) Pointers


}

OUT printf("string")
decl​ara​tion 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​<fi​las​;i++){
unsigned short %hu Files ​ ​ ​ ​ ​ ​ ​ ​fre​e(m​atr​iz[i]);
int %i / %d ​ ​ ​ }
FILE *pointer
unsigned int %u pointer = fope​n ​("f​ile​s", "​mo​de​")
​ ​ ​ ​fre​e(m​atriz);

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
fsee​k​( p​oin​ter, size, whence: )
struct struct_files *arrayFiles;
string %s S​​ EEK​​_S​ET​ ​In​icio void reserv​arS​tru​ct​(int
S​​ EEK​​_C​UR​ Pos actual nElem​entos, struct struct​_fi​les*
Format
S​​ EEK​​_E​ND​ ​Final array​Fil​es){
%0.n​ f n decimales ​ ​ ​
fclo​se​(p​ointer)
%nd Tamaño (espacios pre) ​ ​ ​ ​ ​arr​ayFiles = (struct

%0nd Tamaño (0 pre) struct​_fi​les*)


File Open: mode - operation - exist
mall​oc​( ​si​zeo​f ​(struct
r read N: NULL
Char Array -> String struct​_files) * nEleme​ntos);
w write Y: overw N: create }
void qs(char *cad){
a append N: create
​ ​ ​ ​ i​f ​(ca​d[s​trl​en(​cad​)-
r+ read/​write N: NULL Liberar struct
1​]==​'\n'){
​ ​ ​ ​ ​ ​ ​ ​cad​[st​rle​n(c​ad)​-1]​='\0'; w+ read/​write Y: overw N: create void liberarStruct(struct

​ ​ ​ } struct_files* arrayFiles){
a+ read/app N: create
} ​ ​ ​
Mb binary
​ ​ ​ ​ f​ree​(​arr​ayF​iles);
}

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 =
fope​n​("fi​les.da​t","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

You might also like