Caute ludia, chcel by som sa opytat ci by bol niekto ochotny spravit mi v moznosti "case 'E':" jednu funkciu pre vyhladanie zadaneho slova a moznosti upravy celeho riadku v ktorom sa slovo bude nachadzat.. uz sa s touto funciou stvem niekolko hodin a neviem si rady .. som zaciatocnik cize to bude asi preto :) a by mi niekto pomohol bol by som vdacny :) ak niekto nechape rad vysvetlim znova :D Vopred dakujem :) Program je robeny v Dev-c++ a je to program .C :)
#include <stdio.h>
int main(void)
{
FILE *a;
int tm,em,mm,scm,gu,sno,c,n=0;
char sname[20],any[1],sm[20],hm[20], index,hladacik;
printf("***************************\n---------\nZadajte:\n---------\n Z:Zapis\n V:Vypis\n E:Edit\n Q:Quit\n D:Zmazanie databazy\n*************************** \n");
printf("Zadajte vasu volbu: ");
scanf("%s", &index);
switch(index)
{
case 'Z':
do
{
a=fopen("notebook.txt","a");
system("cls");
printf("******************************\n*Vitajte v zapise do databazy*\n******************************\n\n\n");
printf("Zadajte cislo notebooku : ");
scanf("%s",sno);
printf("Zadajte znacku notebooku : ");
scanf("%s",sname);
printf("Zadajte frekvenciu procesora(MHz) : ");
scanf("%d",&tm);
printf("Zadajte RAM pamät : ");
scanf("%d",&em);
printf("Zadajte velkkost HDD (GB) : ");
scanf("%d",&mm);
printf("Zadajte uhlopriecku notebooku : ");
scanf("%d",&scm);
printf("Zadajte OS notebooku : ");
scanf("%s",&sm);
printf("Zadajte graficku kartu notebooku : ");
scanf("%s",&hm);
printf("Zadali ste: ");
fprintf(a,"%d",&sno);
fprintf(a,"%s %d %d %d %d %s %s\n",sname,tm,em,mm,scm,sm,hm);
printf("Chcete pokracovat?(Y/N)");
scanf("%s",any);
}
while(strcmp(any,"y")==0);
fclose(a);
break;
case 'V':
a=fopen("notebook.txt","r");
system("cls");
printf("****************************\n*Vitajte vo vypise databazy*\n****************************\n\n");
while(feof(a)==0)
{
fscanf(a, "%d ", &sno);
fscanf(a, "%s ", sname);
fscanf(a, "%d ", &tm);
fscanf(a, "%d ", &em);
fscanf(a, "%d ", &mm);
fscanf(a, "%d ", &scm);
fscanf(a, "%s ", sm);
fscanf(a, "%s ", hm);
printf("%d %s %d %d %d %d %s %s\n", sno,sname,tm,em,mm,scm,sm,hm);
}
fclose(a);
system("PAUSE");
break;
case 'D':
if( remove( "notebook.txt" ) != 0 )
perror( "Error pri mazani databazy!" );
else
printf( "Databaza bola zmazana!\n" );
system("PAUSE");
break;
case 'Q': system("cls");
printf("**********************\n*Ukoncili ste program*\n**********************\n");
system("PAUSE");
exit(0);
return 0;
break;
case 'E':
a=fopen ("notebook.txt","r");
system("cls");
printf("*****************************\n*Vitajte v editacii databazy*\n*****************************\n\n");
printf("Zadajte klucove slovo: ");
scanf("%s", &hladacik);
if (a==NULL) perror ("Error pri otvarani suboru");
else
do
{
c==fgets(hladacik,10, a);
if (c!=NULL) n++;
}
while(c!=EOF);
fclose(a);
system("PAUSE");
break;
default : printf("Zle zadane\n");
system("PAUSE");
return 0;
}
}