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

Beispiele 25.10.2021

parent 1e47698c
No related branches found
No related tags found
No related merge requests found
Showing
with 269 additions and 1 deletion
#include <stdio.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
fprintf (f, "Hello, world!\n");
fclose (f);
return 0;
}
#include <stdio.h>
#include <errno.h>
#include <string.h>
int main (void)
{
FILE *f = fopen ("/irgendwo/fhello.txt", "w");
if (f)
{
fprintf (f, "Hello, world!\n");
fclose (f);
}
else
{
char *msg = strerror (errno);
fprintf (stderr, "%s\n", msg);
}
return 0;
}
#include <stdio.h>
#include <errno.h>
#include <string.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
if (f)
{
fprintf (f, "Hello, world!\n");
fclose (f);
}
else
{
char *msg = strerror (errno);
fprintf (stderr, "%s\n", msg);
}
return 0;
}
#include <stdio.h>
#include <errno.h>
#include <string.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
if (f)
{
fprintf (f, "Hello, world!\n");
fclose (f);
return 0;
}
else
{
char *msg = strerror (errno);
fprintf (stderr, "%s\n", msg);
return 1;
}
}
#include <stdio.h>
#include <errno.h>
#include <string.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
if (f)
{
fprintf (f, "Hello, world!\n");
fclose (f);
return 0;
}
else
{
char *msg = strerror (errno);
fprintf (stderr, "%s\n", msg);
return errno;
}
}
#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;
}
#include <stdio.h>
#include <errno.h>
#include <error.h>
int main (void)
{
char *filename = "fhello.txt";
FILE *f = fopen (filename, "w");
if (!f)
{
char buffer[100];
sprintf (buffer, "cannot open file \"%s\"", filename);
error (errno, errno, buffer);
}
fprintf (f, "Hello, world!\n");
fclose (f);
return 0;
}
#include <stdio.h>
#include <errno.h>
#include <error.h>
int main (void)
{
char *filename = "fhello.txt";
FILE *f = fopen (filename, "w");
if (!f)
{
char buffer[5];
sprintf (buffer, "cannot open file \"%s\"", filename);
error (errno, errno, buffer);
}
fprintf (f, "Hello, world!\n");
fclose (f);
return 0;
}
#include <stdio.h>
#include <errno.h>
#include <error.h>
int main (void)
{
char *filename = "fhello.txt";
FILE *f = fopen (filename, "w");
if (!f)
{
char buffer[5];
snprintf (buffer, 5, "cannot open file \"%s\"", filename);
error (errno, errno, buffer);
}
fprintf (f, "Hello, world!\n");
fclose (f);
return 0;
}
#include <stdio.h>
#include <errno.h>
#include <error.h>
int main (void)
{
char *filename = "fhello.txt";
FILE *f = fopen (filename, "w");
if (!f)
{
char buffer[5];
snprintf (buffer, 5, "cannot open file \"%s\"", filename);
buffer[4] = 0;
error (errno, errno, buffer);
}
fprintf (f, "Hello, world!\n");
fclose (f);
return 0;
}
#include <stdio.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
fprintf (f, "Hello, world!\n");
return 0;
}
#include <stdio.h>
#include <unistd.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
fprintf (f, "Hello, world!\n");
sleep (60);
return 0;
}
#include <stdio.h>
#include <unistd.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
fprintf (f, "Hello, world!\n");
fclose (f);
sleep (60);
return 0;
}
#include <stdio.h>
#include <unistd.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
fprintf (f, "Hello, world!\n");
sleep (60);
fclose (f);
return 0;
}
#include <stdio.h>
#include <unistd.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
fprintf (f, "Hello, world!\n");
fflush (f);
sleep (60);
fclose (f);
return 0;
}
#include <stdio.h>
#include <unistd.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>
int main (void)
{
FILE *f = fopen ("/irgendwo/fhello.txt", "w");
if (f)
{
fprintf (f, "Hello, world!\n");
fclose (f);
}
else
fprintf (stderr, "error #%d\n", errno);
return 0;
}
No preview for this file type
...@@ -688,7 +688,7 @@ ...@@ -688,7 +688,7 @@
{ {
FILE *f = fopen ("fhello.txt", "w"); FILE *f = fopen ("fhello.txt", "w");
if (!f) if (!f)
error (1, errno, "cannot open file"); error (errno, errno, "cannot open file");
fprintf (f, "Hello, world!\n"); fprintf (f, "Hello, world!\n");
fclose (f); fclose (f);
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment