Document information
- University
- Politecnico di Milano
- Degree programme
- Aerospace Engineering
- Subject
- Informatica
- Material language
- Italian
- Classification
- Other study material
- Original format
- Text
- Searchable text
Study material for Informatica, shared by the Studwiz community and reviewed by moderators.
Study material for Informatica, shared by the Studwiz community and reviewed by moderators.
Import quality: text was extracted directly from the original document.
Representative passages recognised in different parts of the material. The full extracted text remains available to search, while this compact preview makes the page easier to read.
COSTRUTTI printf("Inserire A"); scanf("%d", &a); fflush(stdin); (se prendo in input più caratteri) if(expression){ corpo_if; }else {corpo_else; } while (expression) {statement; } do{ statement;} while (expression); for(init_instr; expression; loop_instr) {statement; } switch(int_expr) { case constant-expr1: statement1 … case constant-exprN: statementN default :statement } VETTORI e STRINGHE for(i = 0; i < MAX_LEN; i++) { printf("Inserire elemento posizione %d", i+1); scanf("%d", &v1[i]); v2[i] = v1[i]; } scanf ("%s" , stringa); (N.B. Hanno già il terminatore) gets (stringa); printf("Io abito a %s", stringa); int len= strlen(stringa); int ris= strcmp(s1 , s2); (N.B. Le stringhe str1e str2devono terminare con ‘\0’) strcpy (s1 , s2); (copia s2 in s1) strcat(s1 , s2); (accoda s2 ad s1) MATRICI for(i = 0; i < r; i++) { for(j = 0; j < c ; j++){ printf("Inserire elemento posizione [%d][%d]", i+1 , j+1); scanf("%d", &M[i][j]); } } STRUCT struct{ tipo1 nomeCampo1; … tipoN nomeCampoN; } nome; nomeStruct.nomeCampo; FUNZIONI tipo_ritorno nome_funzione(tipo parametro1, tipo par2, …) { // Corpo della funzione return … something … ; } N.B. Una funzione può ritornare: ● Un tipo semplice (char, int, float, …) ● Una struttura (struct persona) ● Un puntatore di un tipo semplice o a una struttura (char*, int*, struct persona*, …) ● Void Non è possibile ritornare vettori né matrici! INIZIALIZZAZIONE int a=1; char iniz_nome= ‘G’; tipo nome_Array [Dimensione]; (N.B. Gli array richiedono cicli per printf e scanf oppure uso i puntatori) char stringa [100]; (99 caratteri + ‘\0’) tipo matrice[dim.riga][dim.col]; typedef nomeTipo NuovoNomeTipo; (EX: typedef char stringa_t[30]; stringa_t stringa1;) tipo* puntatore = &variabile; (indirizzo della cella di memoria) oppure tipo* puntatore; puntatore=…
First page of the document.