/*************************************************************************** main.c - description ------------------- begin : Don Mai 31 21:19:46 CEST 2001 copyright : (C) 2001 by Sebastian Roth email : sebbi@claranet.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ /*************************************************************************** * Corrections and advices by Konrad Rosenbaum * ***************************************************************************/ #define DATNAME "werte.txt" static const int MAXZEILENLAENGE = 160; void wertemain(); void wertemain(void) { FILE *fhd; char s[MAXZEILENLAENGE]; char g_var[4]; g_var[0] = '>'; printf("Bitte die gesuchte Variable eingeben: "); scanf("%s",&g_var[1]); g_var[2] = '<'; g_var[3] = 0; fhd=fopen(DATNAME,"r"); if(!fhd){ printf("Variablendatei konnte nicht geoeffnet werden!\n\n"); }else{ printf("Gesucht war %c\n",g_var[1]); printf("Folgende Variablen stimmen überein:\n\n"); fgets(s,MAXZEILENLAENGE,fhd); do{ while(strstr(s,g_var)){ printf("%s",s); break; } fgets(s,MAXZEILENLAENGE,fhd); } while(!feof(fhd)); fclose(fhd); } }