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

Beispielprogramme und Praktikumstermine 23.10.2017

parent b8815297
No related branches found
No related tags found
No related merge requests found
Showing with 222 additions and 0 deletions
Hello, world!
#include <stdio.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
fprintf (f, "Hello, world!\n");
fclose (f);
return 0;
}
#include <stdio.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
if (f)
{
fprintf (f, "Hello, world!\n");
fclose (f);
}
return 0;
}
#include <stdio.h>
#include <errno.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
if (f)
{
fprintf (f, "Hello, world!\n");
fclose (f);
}
else
fprintf (stderr, "error #%d\n", errno);
return 0;
}
#include <stdio.h>
#include <errno.h>
#include <error.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
if (!f)
error (1, errno, "cannot open file");
fprintf (f, "Hello, world!\n");
fclose (f);
return 0;
}
#include <stdio.h>
#include <errno.h>
#include <error.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
if (!f)
error (errno, errno, "cannot open file");
fprintf (f, "Hello, world!\n");
fclose (f);
return 0;
}
PRAKTIKUMSTERMINE
=================
Mi 08.11.2017
Mi 15.11.2017
(Versuch 2)
#include <stdio.h>
int main (void)
{
char hello_world[] = "Hello, world!\n";
int i = 0;
while (hello_world[i])
printf ("%d", hello_world[i++]);
return 0;
}
#include <stdio.h>
int main (void)
{
char p[] = "Hello!\n";
p[1] = 'a';
printf ("%s", p);
return 0;
}
#include <stdio.h>
int main (void)
{
const char *p = "Hello!\n";
p[1] = 'a';
printf ("%s", p);
return 0;
}
#include <stdio.h>
int main (void)
{
char hello_world[] = "Hello, world!\n";
int i = 0;
while (hello_world[i])
printf ("%c", hello_world[i++]);
return 0;
}
#include <stdio.h>
int main (void)
{
char hello_world[] = { 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33, 10, 0 };
int i = 0;
while (hello_world[i])
printf ("%c", hello_world[i++]);
return 0;
}
#include <stdio.h>
int main (void)
{
char hello_world[] = { 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33, 10 };
int i = 0;
while (hello_world[i])
printf ("%c", hello_world[i++]);
return 0;
}
#include <stdio.h>
int main (void)
{
int hello_world[] = "Hello, world!\n";
int i = 0;
while (hello_world[i])
printf ("%c", hello_world[i++]);
return 0;
}
#include <stdio.h>
int main (void)
{
char hello_world[] = "Hello, world!\n";
char *p = hello_world;
while (*p)
printf ("%c", *p++);
return 0;
}
#include <stdio.h>
int main (void)
{
char *p = "Hello, world!\n";
while (*p)
printf ("%c", *p++);
return 0;
}
#include <stdio.h>
int main (void)
{
char *p = "Hello, world!\n";
printf ("%s", p);
return 0;
}
#include <stdio.h>
int main (void)
{
char *p = "Hello!\n";
p[1] = 'a';
printf ("%s", p);
return 0;
}
#include <stdio.h>
typedef struct
{
char day, month;
int year;
}
date;
void set_date (date *d)
{
(*d).day = 23;
(*d).month = 10;
(*d).year = 2017;
}
int main (void)
{
date today;
set_date (&today);
printf ("%d.%d.%d\n", today.day, today.month, today.year);
return 0;
}
#include <stdio.h>
typedef struct
{
char day, month;
int year;
}
date;
void set_date (date *d)
{
d->day = 23;
d->month = 10;
d->year = 2017;
}
int main (void)
{
date today;
set_date (&today);
printf ("%d.%d.%d\n", today.day, today.month, today.year);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment