cs:c_language:strings_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/cs/c_language/strings_1?do=diff&rev2%5B0%5D=&rev2%5B1%5D=1551188114&difftype=sidebyside
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | cs:c_language:strings_1 [2024/04/08 22:35] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Strings (Example 1) ====== | ||
+ | **Concepts: | ||
+ | String and library functions for their manipulation (library '' | ||
+ | **Text:**\\ | ||
+ | Implements a C program that: | ||
+ | * declares three strings (i.e., arrays of characters), | ||
+ | * prints '' | ||
+ | * acquires a string in '' | ||
+ | * copy '' | ||
+ | * prints '' | ||
+ | * prints the length of '' | ||
+ | * reduces the dimension of '' | ||
+ | * prints the new obtained string '' | ||
+ | * compares the content of '' | ||
+ | |||
+ | **Solution: | ||
+ | <file C string_1.c> | ||
+ | /* | ||
+ | Example about the utilization of strings and the string.h library | ||
+ | */ | ||
+ | |||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | #define N 20 | ||
+ | |||
+ | int main(){ | ||
+ | char str1[N], str2[N], str3[]=" | ||
+ | |||
+ | printf(" | ||
+ | | ||
+ | / | ||
+ | gets(str1); /* Read the whole line */ | ||
+ | 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/cs/c_language/strings_1?do=diff&rev2%5B0%5D=&rev2%5B1%5D=1551188114&difftype=sidebyside
/web/htdocs/www.skenz.it/home/data/pages/cs/c_language/strings_1.txt · Last modified: 2024/04/08 22:35 by 127.0.0.1