Benutzer-Werkzeuge

Webseiten-Werkzeuge


c

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Nächste Überarbeitung
Vorhergehende Überarbeitung
c [2016-04-12 22:49:59] – Externe Bearbeitung 127.0.0.1c [2021-11-06 20:00:14] (aktuell) david
Zeile 19: Zeile 19:
 === stdin2syslogd === === stdin2syslogd ===
  
-  #include <stdio.h> +<code c> 
-  #define SYSLOG_NAMES +#include <stdio.h> 
-  #include <syslog.h> +#define SYSLOG_NAMES 
-  #include <stdlib.h> +#include <syslog.h> 
-  #include <string.h> +#include <stdlib.h> 
-   +#include <string.h> 
-   + 
-  int main(int argc, const char *argv[]) +int main(int argc, const char *argv[]) 
-  {+{
     if (3 != argc)     if (3 != argc)
     {     {
-      fprintf(stderr, "Usage: stdin2syslogd priority syslog-tag\n"); +        fprintf(stderr, "Usage: stdin2syslogd priority syslog-tag\n"); 
-      exit (1);+        exit (1);
     }     }
-  +
     const char *priority_name = argv[1];     const char *priority_name = argv[1];
     const char *tag_name = argv[2];     const char *tag_name = argv[2];
Zeile 42: Zeile 42:
     for (i = 0; prioritynames[i].c_name; ++i)     for (i = 0; prioritynames[i].c_name; ++i)
     {     {
-      if (! strcmp(prioritynames[i].c_name, priority_name)) +        if (! strcmp(prioritynames[i].c_name, priority_name)) 
-      +        
-        priority = prioritynames[i].c_val; +            priority = prioritynames[i].c_val; 
-        break; +            break; 
-      }+        }
     }     }
      
     if (priority < 0)     if (priority < 0)
     {     {
-      fprintf(stderr, "stdin-syslogd: priority \"%s\" not recognized", +        fprintf(stderr, "stdin-syslogd: priority \"%s\" not recognized", 
-        priority_name); +            priority_name); 
-      exit (1);+        exit (1);
     }     }
      
Zeile 64: Zeile 64:
     while (NULL != fgets(buffer, sizeof(buffer), stdin))     while (NULL != fgets(buffer, sizeof(buffer), stdin))
     {     {
-      syslog(priority, "%s", buffer);+        syslog(priority, "%s", buffer);
     }     }
     return 0;     return 0;
-  }+} 
 +</code>
  
   # gcc -o /usr/local/bin/stdin2syslogd stdin2syslogd.c   # gcc -o /usr/local/bin/stdin2syslogd stdin2syslogd.c
Zeile 113: Zeile 114:
 Mit diesem kleinen Programm kann jeder seine Plattform selber kontrollieren. Mit diesem kleinen Programm kann jeder seine Plattform selber kontrollieren.
  
-  #include +<code c> 
-  int main() +#include <stdio.h> 
-  + 
-      printf( "\n char belegt %d Bytes", sizeof( char )); +int main() 
-      printf( "\n int belegt %d Bytes", sizeof( int )); +
-      printf( "\n short belegt %d Bytes", sizeof( short )); +    printf("char belegt %d Bytes\n", sizeof(char)); 
-      printf( "\n long belegt %d Bytes", sizeof( long )); +    printf("int belegt %d Bytes\n", sizeof(int)); 
-      printf( "\n unsigned char belegt %d Bytes", sizeof( unsigned char )); +    printf("short belegt %d Bytes\n", sizeof(short)); 
-      printf( "\n unsigned int belegt %d Bytes", sizeof( unsigned int )); +    printf("long belegt %d Bytes\n", sizeof(long)); 
-      printf( "\n unsigned short belegt %d Bytes", sizeof( unsigned short )); +    printf("unsigned char belegt %d Bytes\n", sizeof(unsigned char)); 
-      printf( "\n unsigned long belegt %d Bytes", sizeof( unsigned long )); +    printf("unsigned int belegt %d Bytes\n", sizeof(unsigned int)); 
-      printf( "\n float belegt %d Bytes", sizeof( float )); +    printf("unsigned short belegt %d Bytes\n", sizeof(unsigned short)); 
-      printf( "\n double belegt %d Bytes\n", sizeof( double )); +    printf("unsigned long belegt %d Bytes\n", sizeof(unsigned long)); 
-      return 0; +    printf("float belegt %d Bytes\n", sizeof(float)); 
-  }+    printf("double belegt %d Bytes\n", sizeof(double)); 
 +    return 0; 
 +} 
 +</code>
  
 siehe: [[http://www.bsdforen.de/showthread.php?t=4894&goto=nextoldest]] siehe: [[http://www.bsdforen.de/showthread.php?t=4894&goto=nextoldest]]
  
  
/home/http/wiki/data/attic/c.1460501399.txt · Zuletzt geändert: von 127.0.0.1