Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp@0:004310a31630, 2019-01-31 (annotated)
- Committer:
- Powers
- Date:
- Thu Jan 31 21:45:30 2019 +0000
- Revision:
- 0:004310a31630
UEBUNG zu Pointer und Array
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Powers | 0:004310a31630 | 1 | #include "mbed.h" |
Powers | 0:004310a31630 | 2 | |
Powers | 0:004310a31630 | 3 | // Uebung um den Unterschied von Array und Pointer auf String klarzumachen |
Powers | 0:004310a31630 | 4 | // Ausgabe - SERIAL |
Powers | 0:004310a31630 | 5 | |
Powers | 0:004310a31630 | 6 | |
Powers | 0:004310a31630 | 7 | void test(void) |
Powers | 0:004310a31630 | 8 | { |
Powers | 0:004310a31630 | 9 | printf("Unterschied zwischen Array und Pointer \n\n\n"); |
Powers | 0:004310a31630 | 10 | |
Powers | 0:004310a31630 | 11 | char x[10] = "abcd"; // Array mit 10 Feldern und dem Inhalt abcd erstellen, viele Felder bleiben leer |
Powers | 0:004310a31630 | 12 | |
Powers | 0:004310a31630 | 13 | printf("char x[10] = \"abcd\";\n\n"); |
Powers | 0:004310a31630 | 14 | printf("Wert in x Gespeichert: %i \n", x); |
Powers | 0:004310a31630 | 15 | printf("Adresse von x: %i \n", &x); |
Powers | 0:004310a31630 | 16 | printf("String im Array x gespeichert: %s\n\n\n", x); |
Powers | 0:004310a31630 | 17 | |
Powers | 0:004310a31630 | 18 | char *y = "abcd"; // Pointer auf abcd welches im Memory - Code Section gespeichert ist |
Powers | 0:004310a31630 | 19 | |
Powers | 0:004310a31630 | 20 | printf("char *y = \"abcd\";\n\n"); |
Powers | 0:004310a31630 | 21 | printf("Wert in y gespeichert: %i \t [Adresse von von abcd in der Code Section of Memory]\n", y); |
Powers | 0:004310a31630 | 22 | printf("Adresse von y: %i \t [Adresse des char Pointers y]\n", &y); |
Powers | 0:004310a31630 | 23 | printf("String von Pointer Adresse: %s", y); |
Powers | 0:004310a31630 | 24 | |
Powers | 0:004310a31630 | 25 | } |
Powers | 0:004310a31630 | 26 | |
Powers | 0:004310a31630 | 27 | |
Powers | 0:004310a31630 | 28 | int main() |
Powers | 0:004310a31630 | 29 | { |
Powers | 0:004310a31630 | 30 | test(); |
Powers | 0:004310a31630 | 31 | return 0; |
Powers | 0:004310a31630 | 32 | } |
Powers | 0:004310a31630 | 33 | |
Powers | 0:004310a31630 | 34 |