Skip to content
Snippets Groups Projects
Commit 7560cc49 authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

weitere Beispiele 17.11.2020

parent bf8b6fff
Branches
No related tags found
No related merge requests found
Showing with 160 additions and 0 deletions
#include <stdio.h>
int main (void)
{
printf ("%d\n", '*');
printf ("%c\n", 71);
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("%d\n", '*');
printf ("%x\n", '*');
printf ("%c\n", 71);
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("%d\n", '*');
printf ("%x\n", '*');
printf ("%c\n", 71);
printf ("%c\n", 0x65);
return 0;
}
#include <stdio.h>
int main (void)
{
char hello[] = "Hello, world!\n";
for (char *p = hello; *p; p++)
printf ("%d", *p);
return 0;
}
#include <stdio.h>
int main (void)
{
char hello[] = { 'H', 'a', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '!', '\n', 0 };
printf ("%s", hello);
return 0;
}
#include <stdio.h>
int main (void)
{
char hello[] = { 'H', 'a', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '!', '\n' };
/* Hier fehlt das Null-Symbol am Ende des Strings!
==> printf() liest über das String-Ende hinaus,
bis es im Speicher zufällig auf eine 0 stößt.
Dies kann zu einem Absturz führen! */
printf ("%s", hello);
return 0;
}
#include <stdio.h>
int main (void)
{
char *hello = "Hello, world!";
printf ("%s\n", hello);
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("%s\n", "Hallo, Welt!");
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("%s\n", "Hallo, Welt!" + 4);
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("Die Ersparnis beträgt %d%%.\n", 42);
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("Die Ersparnis beträgt %d%c.\n", 42, '%');
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("Der Format-String lautet: %s\n", "%02hhx");
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("Добрый день!\n");
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("%s\n", "Добрый день!");
return 0;
}
#include <stdio.h>
int main (void)
{
char hello[] = "Hello, world!\n";
for (char *p = hello; *p; p++)
printf ("%c", *p);
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("%d\n", "Д"); /* Falsch: gibt die Speicheradresse des "Д" aus. */
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("%d\n", 'Д'); /* Der ausgegebene Zahlenwert ist _nicht_ der Unicode für 'Д'. */
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("%08x\n", 'Д'); /* Der ausgegebene Zahlenwert ist _nicht_ der Unicode für 'Д'. */
return 0; /* Für korrekte Handhabung von UTF-8: Bibliothek verwenden. */
}
#include <stdio.h>
int main (void)
{
printf ("%08x\n", 'ä'); /* Der ausgegebene Zahlenwert ist _nicht_ der Unicode für 'ä', */
return 0; /* sondern die UTF-8-Kodierung für 'ä'. */
/* Für korrekte Handhabung von UTF-8: Bibliothek verwenden. */
}
#include <stdio.h>
int main (void)
{
char hello[] = { 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33, 10, 0 };
for (char *p = hello; *p; p++)
printf ("%c", *p);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment