it:informatica:linguaggio_c:stringhe_1
Return to Home page
If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at] skenz.it
You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: https://www.skenz.it/it/informatica/linguaggio_c/stringhe_1?rev=1551188125&do=diff
Differences
This shows you the differences between two versions of the page.
— | it:informatica:linguaggio_c:stringhe_1 [2024/04/08 22:35] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Stringhe (Esempio 1) ====== | ||
+ | **Concetti: | ||
+ | Stringhe e funzioni per la loro manipolazione (libreria // | ||
+ | **Testo: | ||
+ | Si realizzi una programma che: | ||
+ | * dichiari tre stringhe, '' | ||
+ | * stampi '' | ||
+ | * acquisisca una stringa in '' | ||
+ | * copi '' | ||
+ | * stampi '' | ||
+ | * stampi la lunghezza di '' | ||
+ | * riduca la dimensione di '' | ||
+ | * stampi la nuova stringa '' | ||
+ | * compari il contenuto di '' | ||
+ | |||
+ | **Soluzione: | ||
+ | <file C stringhe_1.c> | ||
+ | /* | ||
+ | Esempio di utilizzo delle stringhe | ||
+ | */ | ||
+ | |||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | #define N 20 | ||
+ | |||
+ | int main(){ | ||
+ | char str1[N], str2[N], str3[]=" | ||
+ | |||
+ | printf(" | ||
+ | | ||
+ | / | ||
+ | gets(str1); /* Legge l' | ||
+ | printf(" | ||
+ | |||
+ | strcpy(str2, | ||
+ | printf(" | ||
+ | printf(" | ||
+ | |||
+ | str2[3] = ' | ||
+ | printf(" | ||
+ | |||
+ | if (strcmp(str1, | ||
+ | printf(" | ||
+ | }else{ | ||
+ | printf(" | ||
+ | } | ||
+ | |||
+ | return 0; | ||
+ | } | ||
+ | </ |
If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at] skenz.it
You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: https://www.skenz.it/it/informatica/linguaggio_c/stringhe_1?rev=1551188125&do=diff