update repository
[cmdllinux.git] / bash_n_examples / lang / hello.c
blob42d033502e824d27eb95300ab5fed497e6dee685
1 #include <stdio.h>
2 #include <string.h>
4 void say_goodbye(){
5 printf("Goodbye\n");
8 struct mystruct_t{
9 int value;
10 char letter;
11 char* string;
12 struct{
13 float fp;
14 struct{
15 double dbl;
18 void* ptr;
19 size_t struct_size;
22 int main(void) {
23 printf("Hello World\n");
25 int retval = 1;
27 struct mystruct_t s; // sizeof(struct mystruct_t) bytes are allocated for s, but still contain garbage
28 s.value = 100;
29 s.string = "pass";
30 s.letter = 'P';
31 s.fp = 123.4;
32 s.dbl = 567.8;
33 s.ptr = say_goodbye; // address of function
34 s.ptr = &say_goodbye; // also address of function
35 s.struct_size = sizeof(struct mystruct_t);
37 for(int i=0; i < 2; i++){
38 printf("i is %d\n", i);
41 if(!strcmp(s.string, "pass")){
42 retval = 0;
45 printf("returning %d\n", retval);
46 say_goodbye();
47 return retval;