473,327 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

ADREEs book - mitola

17
#include <stdlib.h>
#include <stdio.h>
#include <string.h>


struct oseba
{
char ime[20];
char priimek[15];
char ulica[50];
char mesto[50];
char tel_st[10];
short ucni_uspeh;
}pod[50];





void vnos(struct oseba pod[],FILE *fd)
{int i;
fd=fopen("DIJAKI.BIN","a+");
for(i=0;i<1;i++)
printf("Vnesi ime: "); scanf("%s",pod[i].ime);
fflush(stdin);
printf("Vnesi priimek: "); scanf("%s",pod[i].priimek);
fflush(stdin);
printf("Vnesi ucni uspeh: "); scanf("%d",&pod[i].ucni_uspeh);
fflush(stdin);
printf("Vnesi ulico in st: ");scanf("%[^\n]s",pod[i].ulica);
fflush(stdin);
printf("Vnesi ime mesta: "); scanf("%s",pod[i].mesto);
fflush(stdin);
printf("Vnesi tel st: "); scanf("%[0-9,-]s",pod[i].tel_st);
fflush(stdin);

fwrite(&pod,sizeof(pod),1,fd);
fclose(fd);
}


void izpis(struct oseba pod[],FILE *fd)
{
fd=fopen("DIJAKI.BIN","r");
fread(&pod,sizeof(pod),1,fd);
fclose(fd);
printf("%s %s\n", pod[0].ime, pod[0].priimek);
printf("Ucni uspeh: %d\n",pod[0].ucni_uspeh);
printf("Ulica: %s\n",pod[0].ulica);
printf("Mesto: %s\n",pod[0].mesto);
printf("Telefonska stevilka: %s\n",pod[0].tel_st);
}


void iskanje(struct oseba pod[],FILE *fd)//pri temule delu potrebujem pomoc matic.
//kako naj pri izbiri ena naredim da najde pac string pa potem
//ga obdelamo oz. izbrisemo
{int a;char iskano[20];
fd=fopen("DIJAKI.BIN","r");

printf("Ali zelis iskati po priimku ali po imenu:\n\n1.) Po imenu\n\n2.) Po priimku\n\n3.) izhod v meni\n\n");
scanf("%d",&a);
system("cls");
int i=0;
if(a==1)
{
printf("\n\nvnesi ime:\n");
scanf("%s",iskano);
while(!feof(fd))
{ //fread(&r,sizeof(struct rec),1,f);
fread(&pod,sizeof(pod),1,fd);
if(strcmp (pod[i].ime,iskano) == 0);// namesto tega probaj dat primerjavo stringov ne strcm,p al pa kej a=b neki probi-***************
{
printf("ime je najdeno.");
system("pause");/*predelaj oz. odstrani ime*//* uredi()*/
i++;
}
}
}

if(a==2)
{
printf("\n\nvnesi priimek:\n");
while(!feof(fd))
{ //fread(&r,sizeof(struct rec),1,f);
/*fread(&pod,sizeof(pod),1,fd);
printf("%s %s\n", pod.ime, pod.priimek);
printf("Ucni uspeh: %d\n",pod.ucni_uspeh);
printf("Ulica: %s\n",pod.ulica);
printf("Mesto: %s\n",pod.mesto);
printf("Telefonska stevilka: %s\n\n\n",pod.tel_st);*/
}
}

if(a==3)
{exit(1);}

else {system("cls");printf("Napacn vnos. Prosim poskusite znova\n\n\n");iskanje(pod,fd);}
fclose(fd);
}


int main(void)
{
FILE *fd;
int a;
int menu;
printf("------------------------------------------------------------------------------- \n");
printf(" IMENIK \n");
printf("------------------------------------------------------------------------------- \n");
printf("Vnesi izbiro:\n");
printf("1.)Vpis podatkov\n");
printf("2.)Izpis vseh podatkov\n");
printf("3.)Iskanje po imenu ali priimku\n");



scanf("%d",&menu);
switch(menu)
{
case 1: vnos(pod,fd);
break;
case 2: izpis(pod,fd);
break;
case 3: iskanje(pod,fd);
break;
}

system("pause");
return 0;
}



well im now stucked cause i dont know how would i wrote more of adresess and details without overwriting previious ones. so i need to find where the inpts stops. and i also have problem to corectly do the fwrite and fread for multi-structure : example : pod[50](structure with more details).

so even explanation of anything above or example would be nice. also if you notice something that could be better please tell me


and im working with DEV-C++ on windows.

thanks for any kind of help in advance
Dec 3 '07 #1
2 1263
mitola
17
and where can i see how to color the code etc.
Dec 3 '07 #2
mitola
17
will possibly anyone answer?
Dec 4 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: anonymous | last post by:
Hi CLCers, I want to know your opinion about the book: Expert C programming-Deep C secrets by Peter Van Der Linden. Thanks in advance. Sha
12
by: Guido Mureddu | last post by:
Hello, I'm a student in electronic engineering. I do know you've seen and answered this sort of topic/request countless times, but I haven't found past threads as helpful as I had hoped, and...
16
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
8
by: Dgates | last post by:
Has anyone typed up an index for the O'Reilly book "C# and VB.NET Conversion?" I'm just learning C#, and often using this little book to see which VB.NET terms translate directly to some term in...
4
by: Mike | last post by:
Hi, I am planning on purchasing VS2005 to learn C# very soon, and I need good book recommendations. I realize this is a question that may be asked a lot, but please consider my background: I...
11
by: www.douglassdavis.com | last post by:
I'm looking for advice here, and I would really appreciate it if you could help. Is there a VB 2005 book that you like and would recommend (and why)? Would you consider it good for...
4
by: Johs | last post by:
I am looking for a good C++ book for beginners. I have some experience with C and a lot of experience with Java. I am currently reading Bjarne Stroustrups C++ Programming Language but it starts off...
7
by: simonZ | last post by:
I would like to buy a book with some windows application example in C# net , but all books I have found are only about theory. I would like to have a book, where is explained how to create...
263
by: Malcolm McLean | last post by:
The webpages for my new book are now up and running. The book, Basic Algorithms, describes many of the fundamental algorithms used in practical programming, with a bias towards graphics. It...
1
by: jrw133 | last post by:
i got this program the other day and ive just started it and i am getting some errors that i cant figure out. requirements: 1)create a clas called Book. a Book has three data members: m_title,...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.