473,406 Members | 2,710 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,406 software developers and data experts.

File Handling Questions(Turbo C)

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<string.h>
  4.  
  5. main(){
  6.   typedef struct info {
  7.           char fname(void),mname(void),famname(void);
  8.           int age,cont;
  9.           char adr;
  10.   } info;
  11. void add(void),del(void);
  12. char select;
  13.  
  14. /*************                  *************/
  15. /***************SCREEN LAYOUT*****************/
  16. /*************                  *************/
  17. clrscr();
  18. system("cls");
  19.  
  20.     printf("            ***** Amount Matrix ***** \n\n");
  21.     printf(" Amount to borrow      Monthly   Quarterly   Semi-Annual   Annual \n");
  22.     printf("                          Interest  Interest    Interest      Interest \n\n");
  23.     printf("  P1,000 below            5%          --           --            --  \n");
  24.     printf("  P1,001 - P10,000        5%          16%          --            --  \n");
  25.     printf("  P10,001 - P50,000       5%          16%          19%           --  \n");
  26.     printf("  P50,001 - P100,000      6%          17%          19%           27% \n");
  27.     printf("  P100,001 - P500,000     6%          17%          20%           29% \n");
  28.     printf("  P500,001 - P1,000,000   7%          18%          21%           30% \n");
  29.  
  30.  
  31. printf("\n\n\t\t\t\n");
  32. printf("\t\t\tMENU                                       \n");
  33. printf("\t\t\t [1] Add Entry                                \n");
  34. printf("\t\t\t [2] Delete Record                                   \n");
  35. printf("\t\t\t [3] Display List                              \n"); 
  36. printf("\t\t\t [4] Search                                    \n");
  37. printf("\t\t\t [5] Save File                                 \n");                                                        
  38. printf("\t\t\t [6] Load File                                 \n");
  39. printf("\t\t\t [7] Quit                                      \n");
  40. printf("\t\t\t\n");
  41. printf("\t\t\t\t Selection: \n\n");
  42.  
  43.  
  44.  
  45. switch(select)
  46. {
  47. case '1': add();
  48. case '2': del();
  49. case '3': disp();
  50. case '4': ser();
  51. case '5': sav();
  52. case '6': lod();
  53. case '7': qit();
  54. case 23: clrscr();
  55. printf("Thank you!");
  56. getch();
  57. exit(0);
  58.  
  59. default: printf("(x)INVALID selection!");
  60. getch();
  61. exit(0);
  62.  
  63. }
  64. {
  65.  
  66. void add(void){
  67. int slot;
  68. slot= find_free();
  69. if(slot== -1){
  70. printf("LIST FULL!");
  71. return;
  72. }
  73. struct{
  74.  
  75. printf("Enter first name: ");
  76. gets(inv_info[slot].fname);
  77. printf("Enter family name: ");
  78. scanf("%s", famname);
  79. printf("Age: ");
  80. scanf("%d%d",&init_info[slot].age);
  81. printf("Address[street|city|province|zip]: ");
  82. scanf("%d%d*c",&init_info[slot].adr);
  83. printf("Contact number[tel/cel]: ");
  84. scanf("%d",%con);
  85. {}
  86.  
  87. }
  88.  
  89. /*************                  *************/
  90. /*************DELETE AN ENTRY**********/
  91. void del(void)
  92. {
  93. register int slot;
  94. char s[100];
  95. printf("Enter Costumer's (family)name: ");
  96. gets(s);
  97. slot= atoi(s);
  98. if(slot>=0 && slot < MAX) info[slot].fname[0]= '\0';
  99. }
  100.  
  101. /*************                  *************/
  102. /*************DISPLAY LIST**********/
  103. void disp(void)
  104. {
  105. register int t;
  106.  
  107. for(t=0; t<MAX; ++t) {
  108. it(inv_info[t].name[0]) {
  109. printf("Name: %s,%s,%s\n", info[t].fname,info[t].mname,info[t].famname);
  110. printf("Age:%s\n", info[t].age);
  111. printf("Address:%s\n",info[t].adr);
  112. printf("Contact number:%d",info[t].con);
  113. }
  114. }
  115. printf("\n\n");
  116. }
  117.  
  118. }
  119.  
  120. /*******************************************************************/
  121. /*     function search    */
  122. /*******************************************************************/
  123. ser()
  124.  
  125. {
  126.  
  127.     int i;
  128.     char name[30];
  129.  
  130.     clrscr();
  131.     inputs("\n\n\t\t Enter name to find: ", famname, 30);
  132.     if((i=find(name))<0)
  133.     printf("\n\n\t\t Name not found.");
  134.     else{
  135.         printf("t%s","-------------------------------------------------\n");
  136.  
  137.         printf("%10%10%10%10%10\n\n","famname","fname","age","adr","con");
  138.     display(i);    
  139.     }
  140.     getch();
  141.     clrscr();
  142.     }
  143.  
  144.  
  145.  
  146. /*******************************************************************/
  147. /*     function save     */
  148. /*******************************************************************/
  149.  
  150. sav(){
  151.  
  152. {
  153.     FILE *fp;
  154.     if((fp=fopen("mlist",:wb))==NULL){
  155.      printf("\n\n\t\t Cannot open file...\n");
  156.     return;
  157.     }
  158.     printf("\n\t\t Saving File...\n\n\n");
  159.     fclose(fp);
  160. }
  161. }
  162.  
  163. lod()
  164. {}/*********************************************************************/
  165. /*      function load           */
  166. /*********************************************************************/
  167. lod()
  168. {
  169.     FILE *fp;
  170.     if((fp=fopen("mlist",:rb))==NULL){
  171.     printf("\t\tCannot open file...\n");
  172.     return;
  173.     }
  174.     printf("\n\t\tLOading Complete...\n\n");
  175.     fread(list, sizeoflist, 1, fp);
  176.     if(ferror(fp))
  177.         printf("An error occured while reading file!\n");
  178.     fclose(fp);
  179. }
  180. qit()
  181. { return 0;
  182. }
  183. }
  184. }
  185.  

hello. everyone! i was just kind'a having trouble with my codes,
could you please check them? hmm.. its not yet finished.. im still gonna add, the range amounts(i'll try if i really can, im not sure =( )
well, for the meantime.. my codes got rumbled, i don't understand them anymore.. but it does give the ff. options..
[1]Add entry
[2]Delete entry
[3]Display list
[4]Search
[5]Save
[6]Load
[7]Quit

and hey, i'd really be so glad if you post some help! (ow, this is for my project anyway..) x] thanks
Mar 24 '09 #1
4 6358
JosAH
11,448 Expert 8TB
And what is your question? You can't expect us to finish your code without even knowing what it's supposed to do.

kind regards,

Jos

ps. The indentation (almost none and inconsistent) of your code stinks.
Mar 24 '09 #2
@JosAH
>> aw, im so sorry.. hmf.
my questions :
1.are the codes correct?what's wrong with it? i couldn't check them my own, cos it too doesn't run. it tells some "expression/ declaration syntax in main function, statement missing".. please help? i just couldn't finish coding it now. [cos, i haven't sleep yet.

thanks.
Mar 24 '09 #3
JosAH
11,448 Expert 8TB
@shaieen
Take some good night sleep first. Compile everything tomorow and post the compiler error message which you don't understand. Your questions now are similar to "do my work for me" and we won't do that.

kind regards,

Jos
Mar 24 '09 #4
guys ,, can anyone post a link on matrix effect code for turbo c?
Oct 6 '11 #5

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

Similar topics

9
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is...
11
by: Josh | last post by:
Hi, I am having a problem with Python. I am new to Python as a programming language, but I do have experience in other languages. I am experiencing strange problems with File handling and wonder...
1
by: Sean W. Quinn | last post by:
Hey folks, I have a question regarding file handling, and the preservation of class structure. I have a class (and I will post snippets of code later in the post) with both primitive data...
9
by: Jay Kim | last post by:
Hi, We're implementing a Windows application using Visual Basic .NET. One of the key features we need to implement is that we should be able to get the accurate byte offset of user selected...
4
by: BHARAT | last post by:
Hi I am a little bit new to C's advanced topics: I need help in file handling. I have Turbo C and I wrote a simple program to write data to file: #include<stdio.h> #include<dir.h>...
7
by: D & J G | last post by:
Is there a way to instruct Windows file-handling - 'Opens with:' - from within VB6? I want to ensure that files with the .rtf (rich text) extension always go to Word Pad, no matter which future...
3
by: Binu C | last post by:
hi am new to VB. I need to develop an application. The requirements are as follows: We have a notepad which consists of some data(Say A). Now we have a form in which we have some text fields & a...
9
by: lokeshrajoria | last post by:
hello everybody, i need some help in binary file handling in perl. can anybody give me some information about binary file. actully i am reading data from some text file and extracting some usefull...
3
by: neha_chhatre | last post by:
hey please help me execute the code on ubuntu in C #include<stdio.h> #include<stdlib.h> int main() { FILE *fp; char ch; float ticktock;
2
by: phpmagesh | last post by:
Hi, I want to create a xml document using php-file handling . that i have a Database named as Total_category and table name as students_one. and i have fields like name, age, email, title,...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.