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

Beispiele 26.10.2023

parent efb0aab6
Branches
No related tags found
No related merge requests found
Showing
with 212 additions and 8 deletions
#include <stdio.h>
#include <string.h>
int main (void)
{
char hello[] = "Hello, world!\n";
printf ("%s\n", hello);
printf ("%zd\n", strlen (hello));
printf ("%s\n", hello - 7);
printf ("%zd\n", strlen (hello - 7));
return 0;
hello[5] = 0;
printf ("%s\n", hello);
printf ("%zd\n", strlen (hello));
return 0;
}
#include <stdio.h>
#include <string.h>
int main (void)
{
char hello[] = "Hello, world!\n";
printf ("%s\n", hello);
printf ("%zd\n", strlen (hello));
printf ("%s\n", hello - 1);
printf ("%zd\n", strlen (hello - 1));
return 0;
hello[5] = 0;
printf ("%s\n", hello);
printf ("%zd\n", strlen (hello));
return 0;
}
#include <stdio.h>
#include <string.h>
int main (void)
{
char hello[] = "Hello, world!\n";
printf ("%s\n", hello);
printf ("%zd\n", strlen (hello));
printf ("%s\n", hello - 1);
printf ("%zd\n", strlen (hello - 1));
return 0;
hello[5] = 0;
printf ("%s\n", hello);
printf ("%zd\n", strlen (hello));
return 0;
}
#include <stdio.h>
#include <string.h>
int main (void)
{
char hello[] = "Hello, world!\n";
printf ("%s\n", hello);
printf ("%zd\n", strlen (hello));
printf ("%s\n", hello + 17);
printf ("%zd\n", strlen (hello + 17));
return 0;
hello[5] = 0;
printf ("%s\n", hello);
printf ("%zd\n", strlen (hello));
return 0;
}
#include "answer.h"
int answer (void)
{
return 23;
}
extern int answer (void);
...@@ -9,7 +9,7 @@ static void activate (GtkApplication *app, gpointer user_data) ...@@ -9,7 +9,7 @@ static void activate (GtkApplication *app, gpointer user_data)
int main (int argc, char **argv) int main (int argc, char **argv)
{ {
GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", G_APPLICATION_DEFAULT_FLAGS); GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.gtk-01", G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
int status = g_application_run (G_APPLICATION (app), argc, argv); int status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app); g_object_unref (app);
......
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <stdio.h>
static void hello (GtkWidget *this, gpointer user_data) static void hello (GtkWidget *this, gpointer user_data)
{ {
...@@ -18,7 +19,7 @@ static void activate (GtkApplication *app, gpointer user_data) ...@@ -18,7 +19,7 @@ static void activate (GtkApplication *app, gpointer user_data)
int main (int argc, char **argv) int main (int argc, char **argv)
{ {
GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", G_APPLICATION_DEFAULT_FLAGS); GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.gtk-02", G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
int status = g_application_run (G_APPLICATION (app), argc, argv); int status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app); g_object_unref (app);
......
#include <stdio.h>
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;
}
#include <stdio.h>
#define NINE 9
#define SIX 6
int main (void)
{
printf ("nine times six = %d\n", NINE * SIX);
return 0;
}
#include <stdio.h>
#define NINE 1 + 8
#define SIX 5 + 1
int main (void)
{
printf ("nine times six = %d\n", NINE * SIX);
return 0;
}
#include <stdio.h>
#define NINE (1 + 8)
#define SIX (5 + 1)
int main (void)
{
printf ("nine times six = %d\n", NINE * SIX);
return 0;
}
#include <stdio.h>
#define NINE (1 + 8)
#define SIX (5 + 1));
int main (void)
{
printf ("nine times six = %d\n", NINE * SIX
return 0;
}
#include <stdio.h>
#define NINE (1 + 8
#define SIX (5 + 1));
int main (void)
{
printf ("nine times six = %d\n", NINE) * SIX
return 0;
}
No preview for this file type
...@@ -514,7 +514,7 @@ ...@@ -514,7 +514,7 @@
int main (void) int main (void)
{ {
date today = { 17, 10, 2022 }; date today = { 26, 10, 2023 };
printf ("%d.%d.%d\n", today.day, today.month, today.year); printf ("%d.%d.%d\n", today.day, today.month, today.year);
return 0; return 0;
} }
...@@ -538,9 +538,9 @@ ...@@ -538,9 +538,9 @@
void set_date (date *d) void set_date (date *d)
{ {
(*d).day = 17; (*d).day = 26;
(*d).month = 10; (*d).month = 10;
(*d).year = 2022; (*d).year = 2023;
}¿ }¿
\end{lstlisting} \end{lstlisting}
\end{minipage}% \end{minipage}%
...@@ -575,9 +575,9 @@ ...@@ -575,9 +575,9 @@
void set_date (date *d) void set_date (date *d)
{ {
d->day = 17; d->day = 26;
d->month = 10; d->month = 10;
d->year = 2022; d->year = 2023;
}¿ }¿
\end{lstlisting} \end{lstlisting}
\end{minipage}% \end{minipage}%
...@@ -1050,7 +1050,7 @@ ...@@ -1050,7 +1050,7 @@
\pause \pause
\smallskip \smallskip
\item \item
Mit \lstinline[style=cmd]{pkg-config --cflags --libs} erfährt man,\\ Mit \lstinline[style=cmd]{pkg-config --cflags --libs gtk4} erfährt man,\\
welche Optionen und Bibliotheken man an \lstinline[style=cmd]{gcc} welche Optionen und Bibliotheken man an \lstinline[style=cmd]{gcc}
übergeben muß\alt<4->{.}{:} übergeben muß\alt<4->{.}{:}
\pause \pause
......
#include <stdio.h>
#include "answer.h"
int main (void)
{
printf ("The answer is %d.\n", answer ());
return 0;
}
#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));
return 0;
char buffer[100] = "Huber ";
strcat (buffer, anton);
printf ("%s\n", buffer);
return 0;
}
#include <stdio.h>
#include <string.h>
int main (void)
{
char *anton = "Anton";
char *zacharias = "Zacharias";
printf ("%d\n", anton < zacharias);
printf ("%d\n", zacharias < anton);
printf ("%d\n", anton == anton);
return 0;
char buffer[100] = "Huber ";
strcat (buffer, anton);
printf ("%s\n", buffer);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment