Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 21st, 2012  |  syntax: C  |  size: 0.83 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include<string.h>
  2.  
  3. void konfIO(int io)
  4. {
  5.         const int devx = 50;    //Device-länge
  6.         const int tmpx = 500;   //tmp-x-länge
  7.         const int tmpy = 500;   //tmp-y-länge
  8.  
  9.         int i;
  10.                
  11.         FILE *config;
  12.        
  13.         char *search;           //suchString   
  14.         char dev[devx];         //neues Device
  15.         char tmpStr[tmpy][tmpx]; //tmp
  16.  
  17.  
  18.         switch(io)
  19.         {
  20.                 case 0:
  21.                         search = "[OUTPUT]";
  22.                         printf("Wie soll das Output-Device heißen?\n");
  23.                         break;
  24.                 case 1:
  25.                         search = "[INPUT]";
  26.                         printf("Wie soll das Input-Device heißen?\n");
  27.                         break;
  28.         }
  29.         fgets(dev, devx, stdin);
  30.  
  31.         config = fopen("config", "r");
  32.         if( config == NULL)
  33.         {
  34.                 //File existiert nicht
  35.         }
  36.         i = 0;
  37.         while(fgets(tmpStr[i], tmpy, config))
  38.         {
  39.                 if(strncmp(tmpStr[i], search, strlen(search)) == 0)
  40.                 {      
  41.                         i++;
  42.                         strcpy(tmpStr[i], dev);
  43.                 }
  44.                 printf("%s", tmpStr[i]);
  45.                 i++;   
  46.         }
  47.         fclose(config);
  48. }