/*************************************************************************** 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 ZEILENLAENGE 300 #define SEARCHSTRLENGTH 3 #define V_SUCHE 3 #define DATNAME "werte.txt" void wertemain(void) { FILE *fhd; char str[ZEILENLAENGE],searchstr[SEARCHSTRLENGTH]; unsigned int line=1; int found=0; printf("Bitte die gesuchte Variable eingeben :"); scanf("%s",searchstr); printf("\n"); if((fhd=fopen(DATNAME,"r"))){ fgets(str,V_SUCHE, fhd); while(!feof(fhd)){ if(strstr(str,searchstr)){ found=1; line--; fgets(str,ZEILENLAENGE,fhd); printf("%s",str); break; } fgets(str,V_SUCHE, fhd); line++; } if(!found){ printf("Die Variable existiert nicht!\n\n"); } fclose(fhd); }else{ printf("\nQuell-Datei konnte nicht geoeffnet werden\n\n"); } }