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

weitere Beispielprogramme 5.11.2018

parent 58c35dcd
Branches
No related tags found
No related merge requests found
Showing
with 165 additions and 1 deletion
#include <stdio.h>
int main (void)
{
printf ("Hello, world!\n");
return 0;
}
int main (void)
{
printf ("Hello, world!\n");
return 0;
}
extern int printf (const char *__restrict __format, ...);
int main (void)
{
printf ("Hello, world!\n");
return 0;
}
extern int schreib_doch_mal (const char *__restrict __format, ...);
int main (void)
{
schreib_doch_mal ("Hello, world!\n");
return 0;
}
#include <library-1.h>
int main (void)
{
schreib_doch_mal ("Hello, world!\n");
return 0;
}
#include "library-1.h"
int main (void)
{
schreib_doch_mal ("Hello, world!\n");
return 0;
}
#include "library-2.h"
int main (void)
{
schreib_doch_mal ("Hello, world!\n");
return 0;
}
eine kleine Hexe.
No preview for this file type
...@@ -179,7 +179,7 @@ ...@@ -179,7 +179,7 @@
{ {
FILE *f = fopen ("fhello.txt", "w"); FILE *f = fopen ("fhello.txt", "w");
if (!f) if (!f)
error (-1, errno, "cannot open file"); error (1, errno, "cannot open file");
fprintf (f, "Hello, world!\n"); fprintf (f, "Hello, world!\n");
fclose (f); fclose (f);
return 0; return 0;
......
#include <stdio.h>
void schreib_doch_mal (char *s)
{
printf ("%s", s);
}
extern int schreib_doch_mal (const char *__restrict __format, ...);
extern int schreib_doch_mal (char *s);
Vor langer, langer Zeit
gab es einmal
#include "hexe.h"
Die lebte in einem Wald.
cassini/home/peter/bo/2018ws/hp/20181105> cat hello-6.c
#include "library-1.h"
int main (void)
{
schreib_doch_mal ("Hello, world!\n");
return 0;
}
cassini/home/peter/bo/2018ws/hp/20181105> cat library-1.h
extern int schreib_doch_mal (const char *__restrict __format, ...);
cassini/home/peter/bo/2018ws/hp/20181105> cat library-1.c
#include <stdio.h>
void schreib_doch_mal (char *s)
{
printf ("%s", s);
}
cassini/home/peter/bo/2018ws/hp/20181105> gcc -Wall -O hello-6.c library-1.c -o hello-6
cassini/home/peter/bo/2018ws/hp/20181105> ./hello-6
Hello, world!
#include <stdio.h>
#include <string.h>
int main (void)
{
char *anton = "Anton";
char *zacharias = "Zacharias";
printf ("%d\n", strcmp (anton, zacharias));
printf ("%d\n", strcmp (zacharias, anton));
printf ("%d\n", strcmp (anton, anton));
char buffer[100] = "Huber ";
strcat (buffer, anton);
printf ("%s\n", buffer);
return 0;
}
#include <stdio.h>
#include <string.h>
int main (void)
{
char buffer[100] = "";
sprintf (buffer, "Die Antwort lautet: %d", 42);
printf ("%s\n", buffer);
return 0;
char *answer = strstr (buffer, "Antwort");
printf ("%s\n", answer);
printf ("found at: %zd\n", answer - buffer);
return 0;
}
#include <stdio.h>
#include <string.h>
int main (void)
{
char buffer[100];
sprintf (buffer, "Die Antwort lautet: %d", 42);
printf ("%s\n", buffer);
return 0;
char *answer = strstr (buffer, "Antwort");
printf ("%s\n", answer);
printf ("found at: %zd\n", answer - buffer);
return 0;
}
#include <stdio.h>
#include <string.h>
int main (void)
{
char buffer[100];
// sprintf (buffer, "Die Antwort lautet: %d", 42);
printf ("%s\n", buffer);
return 0;
char *answer = strstr (buffer, "Antwort");
printf ("%s\n", answer);
printf ("found at: %zd\n", answer - buffer);
return 0;
}
#include <stdio.h>
#include <string.h>
int main (void)
{
char buffer[100] = "";
sprintf (buffer, "Die Antwort lautet: %d", 42);
printf ("%s\n", buffer);
char *answer = strstr (buffer, "Antwort");
printf ("%s\n", answer);
printf ("found at: %zd\n", answer - buffer);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment