473,386 Members | 1,810 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,386 software developers and data experts.

deleting part of file and modyfing it

17
Expand|Select|Wrap|Line Numbers
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5.  
  6. struct oseba
  7. {
  8. char ime[20];
  9. char priimek[15];
  10. char ulica[50];
  11. char mesto[50];
  12. char tel_st[10];
  13. short ucni_uspeh;
  14.  
  15. int stevec;
  16. }pod[4];
  17.  
  18.  
  19.  
  20.  
  21.  
  22. void predelaj_osebo(struct oseba pod[],FILE *fd)
  23. {int izbira;int i=0;
  24.     system("cls");
  25.     printf("Kaj zelis storiti z osebo:");
  26.     printf("\n\n1.)Izbrisati");
  27.     printf("\n\n2.)spremeniti");
  28.     printf("\n\n3.)nic\n\n");
  29.     scanf("%d",&izbira);
  30.  
  31.     switch(izbira)
  32.     {
  33.     case 1:    
  34.             printf("Vnesi ime: ");          scanf("%s",pod[i].ime);
  35.                 fflush(stdin);
  36.             printf("Vnesi priimek: ");            scanf("%s",pod[i].priimek);
  37.                 fflush(stdin);
  38.             printf("Vnesi ucni uspeh: ");   scanf("%d",&pod[i].ucni_uspeh);
  39.                 fflush(stdin);
  40.             printf("Vnesi ulico in st: ");  scanf("%[^\n]s",pod[i].ulica);
  41.                 fflush(stdin);
  42.             printf("Vnesi ime mesta: ");    scanf("%s",pod[i].mesto);
  43.                 fflush(stdin);
  44.             printf("Vnesi tel st: ");          scanf("%[0-9]s",pod[i].tel_st);
  45.                 fflush(stdin);
  46.             //fd=fopen("DIJAKI.BIN","r+");
  47.             fseek(fd, -sizeof(struct oseba), SEEK_CUR);
  48.             fwrite(&pod,sizeof(struct oseba),1,fd);
  49.     break;
  50.     case 2: 
  51.     break;
  52.     case 3: 
  53.     break;
  54.     }
  55. }
  56.  
I have a problem in under-under progam with name predelaj_osebo. I dont know how could i delete certain part of the structure without affecting other part of it.
and how could i just modify one part of the structure pod . for excample pod [2].


thanks in advance
Dec 5 '07 #1
1 1331
primeSo
35
I didn't go throught your code in detail, but roughly know what you want to do.

First of all, for efficiency wise, i want to advice you to pass in the pointer of the structure to the function instead of passing the whole structure one at a time. check this out.

Do you mean that you want to update the value of the variables within your structure? use dot "." operator or "->" short hand operator depends on how you access the sturucture within the function. either instance of the structure or pointer pointing to the instance of the structure. check it out ^.^.
Dec 12 '07 #2

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

Similar topics

8
by: phpfrizzle | last post by:
Hi there, I have built a CMS, and in one part you have to be able to delete images. Structure like this: _root --> folder "img" --> file "1.jpg" --> file "2.jpg" --> folder "CMS" ...
3
by: John Aherne | last post by:
Being a bit of a newbie, I hope this question isn't too stupid. I have searched the archives and docs for any reports about files and csv messages and not found anything that mentions the problem I...
1
by: Sumeeta. | last post by:
Hi, Am new to xml, using the xercess c++ DOM parser . I want to delete a node from the xml file. Have used th removeChild() method...but nothin happens.. not even errors.. it executes but...
3
by: Thaynann | last post by:
is there a way to delete a block of text i have started by looking for the speicific line of text that starts the block by looking for teh index of it...but i cannot figure out out to remove...
13
by: Bob Darlington | last post by:
I have a repair and backup database routine which runs when a user closes down my application. It works fine in my development machine, but breaks on a client's at the following line: If...
0
by: naija naija | last post by:
Hi All, I'm using the TreView Web Control for my MENU. And the Menu is populated from an XML file below. I want a way in which i can manipulate the XML when i want to manage it without having to...
2
by: GMK | last post by:
Dear all in my asp.net application i have a text file that is installed with my application on the server. this text file is filled with data through a web interface in my application. i need to...
5
by: George | last post by:
VB.net 2003 standard, XP windows home edition. Installed first application OK today. When I removed the application via Control Panel, there were no problems and the app folders were deleted. ...
3
by: showson1 | last post by:
Hi all. We have some files that are basically TIF images with a text header. The header portion is blocked by {startdb} and {enddb}.. it is the same format for all the files. What I need to do...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.