943,920 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 645
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Mar 6th, 2009
0

how to convert this to stdio.h and conio.h.convert the cout to printf and etc.

Expand Post »
C++ Syntax (Toggle Plain Text)
  1. #include<fstream.h>
  2. #include<stdio.h>
  3. #include<conio.h>
  4. #include<string.h>
  5. #include<iostream.h>
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8. #include <conio.h>
  9. void deposit(void);
  10. void addrecord();
  11. void delrecord();
  12. void modrecord();
  13. void disprecord();
  14. void dispall();
  15. void withdraw();
  16. float w,z;
  17. class account
  18. {
  19. int accountno,cls;
  20. char name[30],type;
  21. float deposit,withdraw;
  22. public:
  23. account()
  24. {
  25. deposit=withdraw=0;
  26. }
  27. int giveaccountno()
  28. {
  29. return accountno;
  30. }
  31. void getdata(int mrno)
  32. {
  33. accountno=mrno+1;
  34. cout<<"\t\t\tACCOUNT NUMBER:";
  35. cout<<accountno<<" \n";
  36. cout<<"\t\t\tENTER YOUR NAME:";
  37. gets(name);
  38. cout<<" ";
  39. cout<<"\t\t\tENTER TYPE OF ACCOUNT SAVING(s)/CURRENT(c):";
  40. cin>>type;
  41. cout<<" ";
  42. cout<<"\t\t\tENTER INITIAL AMOUNT:Php.";cin>>deposit;
  43. cout<<" ";
  44. clrscr();
  45. }
  46. void withdrawal(int m)
  47. {
  48. cout<<"\n\n\n\n\n\n\n\n\n\t\tAMOUNT BEFORE WITHDRAWING:Php."<<deposit<<"";
  49. deposit=deposit-m;
  50. cout<<"\n\n\t\tAMOUNT AFTER WITHDRAWING:Php."<<deposit;
  51. }
  52. void deposital(int m)
  53. {
  54. cout<<"\n\n\n\n\n\n\n\n\n\t\tAMOUNT BEFORE DEPOSIT:Php."<<deposit<<"";
  55. deposit=deposit+m;
  56. cout<<"\n\n\t\tAMOUNT AFTER DEPOSIT :Php."<<deposit;
  57. }
  58. void dispdata()
  59. {
  60. int scrnt=0;
  61. if(scrnt==1)
  62. {
  63. clrscr();
  64. cout<<"\t\t\tDISPLAY ALL MENU ";
  65. scrnt=0;
  66. }
  67. cout<<"\n\t\t\tACCOUNT NUMBER:";
  68. cout<<accountno;
  69. cout<<"\n\t\t\tNAME OF DEPOSITOR:";
  70. cout<<name;
  71. cout<<"\n\t\t\tTYPE OF ACCOUNT SAVING(s)/CURRENT(c):";
  72. cout<<type;
  73. cout<<"\n\t\t\tBALANCE :Php.";
  74. cout<<deposit;
  75. scrnt++;
  76. }
  77. };
  78.  
  79. void main()
  80. {
  81. int menuch;
  82.  
  83. do
  84. {
  85. clrscr();
  86. textcolor(14);
  87. textbackground(1);
  88. cout<<"\n\t\t\tKIKIMUT BANKING SYSTEM...";
  89. cout<<"\n\n\n\n\n\n\n\n\t\t\tMAIN MENU\n";
  90. cout<<"\n\t\t\t1.NEW ACCOUNT";
  91. cout<<"\n\t\t\t2.CLOSE AN ACCOUNT";
  92. cout<<"\n\t\t\t3.MODIFY AN ACCOUNT";
  93. cout<<"\n\t\t\t4.DISPLAY AN ACCOUNT";
  94. cout<<"\n\t\t\t5.DISPLAY ALL RECORDS";
  95. cout<<"\n\t\t\t6.WITHDRAW AMOUNT";
  96. cout<<"\n\t\t\t7.DEPOSIT AMOUNT";
  97. cout<<"\n\t\t\t8.EXIT";
  98. cout<<"\n\t\t\tENTER YOUR CHOICE:";
  99. cin>>menuch;
  100.  
  101. switch(menuch)
  102. {
  103.  
  104. case 1:addrecord();break;
  105. case 2:delrecord();break;
  106. case 3:modrecord();break;
  107. case 4:disprecord();break;
  108. case 5:dispall();break;
  109. case 6:withdraw();break;
  110. case 7:deposit();break;
  111. }
  112. }
  113. while(menuch!=8);
  114. }
  115. void addrecord()
  116. {
  117. account obj_1,obj_2;
  118. fstream fout;
  119. fout.open("banking.txt",ios::in|ios::binary);
  120. if(!fout)
  121. {
  122. clrscr();
  123. cout<<"\n\n\n\n\n\n\n\n\n\t\t\tFILE OPEN ERROR";getch();return;}
  124. int recsize=sizeof(account);
  125. fout.seekg(0,ios::end);
  126. fout.seekg(-1*recsize,ios::cur);
  127. fout.read((char*)&obj_1,recsize);
  128. int mrno=obj_1.giveaccountno();
  129. fout.close();
  130. clrscr();
  131. cout<<"\n\n\n\n\n\n\n\n\n\t\t\t\tADD MENU\n";
  132. obj_2.getdata(mrno);
  133. fout.open("banking.txt",ios::app|ios::binary);
  134. if(!fout)
  135. {
  136. cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\tFILE OPEN ERROR";getch();return;}
  137. fout.write((char*)&obj_2,recsize);
  138. cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\tRECORD ADDED TO DATABASE\n"<<"\n\t\t\tPress any key to continue... ";
  139. getch();
  140. fout.close();
  141. }
  142. void dispall()
  143. {
  144. account obj_3;
  145. fstream fout;
  146. int recsize=sizeof(account);
  147. int countrec=0;
  148. clrscr();
  149. cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\tDISPLAY ALL MENU\n\n ";
  150. fout.open("banking.txt",ios::in);
  151. if(!fout)
  152. {
  153. clrscr();
  154. cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\tFILE OPEN ERROR ";getch();return;}
  155. while(fout.read((char*)&obj_3,recsize))
  156. {
  157. obj_3.dispdata();
  158. countrec++;
  159. cout<<"\n\n\t\t\tPRESS ANY KEY FOR NEXT....\n\n";
  160. getch();
  161. }
  162. clrscr();
  163. cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\tEND OF FILE.TOTAL NUMBER OF RECORDS..."<<countrec;
  164. cout<<"\n\n\t\t\tPress any key to continue......";
  165. getch();
  166. fout.close();}
  167. void disprecord()
  168. {
  169. account obj_4;
  170. fstream fout;
  171. int mrno,flag=0;
  172. int recsize=sizeof(account);
  173. clrscr();
  174. cout<<"\n\n\n\n\n\n\n\n\n\t\t\tDISPLAY A RECORD MENU\n";
  175. fout.open("banking.txt",ios::in);
  176. if(!fout)
  177. {
  178. clrscr();
  179. cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\tFILE OPEN ERROR ";getch();return;}
  180. cout<<"\n\t\t\tENTER THE ACCOUNT NUMBER:";cin>>mrno;
  181. while(fout.read((char*)&obj_4,recsize))
  182. {
  183. if (obj_4.giveaccountno()==mrno)
  184. {
  185. obj_4.dispdata();
  186. cout<<"\n\n\t\t\tPress any key to continue.....";
  187. flag=1;break;
  188. }
  189. }
  190. if(flag==0)
  191. {
  192. clrscr();
  193. cout<<"\n\n\n\n\n\n\n\n\n\t\t\tNO SUCH ACCOUNT EXIST";
  194. cout<<"\n\t\t\tPress any key......";
  195. }
  196. getch();
  197. fout.close();
  198. }
  199. void delrecord()
  200. {
  201. account obj_5;
  202. fstream fout,temp;
  203. int mrno,flag;
  204. int recsize=sizeof(account);
  205. clrscr();
  206. cout<<"\n\n\n\n\n\n\n\n\n\t\t\tCLOSE ACCOUNT MENU\n";
  207. fout.open("banking.txt",ios::in);
  208. if(!fout)
  209. {
  210. clrscr();
  211. cout<<"\n\n\n\n\n\n\n\n\n\t\t\t\tFILE OPEN ERROR";
  212. getch();
  213. return;
  214. }
  215. temp.open("temp.txt",ios::app|ios::binary);
  216. if(!temp)
  217. {
  218. clrscr();
  219. cout<<"\n\n\n\n\n\n\n\n\n\n\t\t\t\tFILE OPEN ERROR";
  220. getch();
  221. return;
  222. }
  223. cout<<"\n\t\t\tENTER THE ACCOUNT NUMBER:";
  224. cin>>mrno;
  225. clrscr();
  226. while(fout.read((char*)&obj_5,recsize))
  227. {
  228. if(obj_5.giveaccountno()==mrno)
  229. {
  230. obj_5.dispdata();
  231. char confirm;
  232. clrscr();
  233. cout<<"\n\n\n\n\n\n\n\n\n\t\t\tARE YOU SURE TO DELETE IT(Y/N)..";cin>>confirm;
  234. if(confirm=='Y'||confirm=='y')
  235. {
  236. fout.read((char*)&obj_5,recsize);
  237. clrscr();
  238. cout<<"\n\n\n\n\n\n\n\n\n\t\t\tRECORD DELETED FROM DATABASE\n";
  239. cout<<"\n\t\t\tpress any key to continue....";
  240. flag=1;
  241. if(!fout)
  242. break;
  243. }
  244. flag=1;
  245. }
  246. temp.write((char*)&obj_5,recsize);}
  247. fout.close();
  248. temp.close();
  249. remove("banking.txt");
  250. rename("temp.txt","banking.txt");
  251. if(flag==0)
  252. {
  253. cout<<"NO SUCH ACCOUNT EXIST\n";
  254. cout<<"Press any key to continue.....\n";
  255. }
  256. getch();
  257. }
  258. void modrecord()
  259. {
  260. account obj_6;
  261. fstream fout;
  262. int mrno,flag=0;
  263. int recsize=sizeof(account);
  264. clrscr();
  265. cout<<"\n\n\n\n\n\n\n\n\n\t\t\tMODIFY RECORD MENU\n";
  266. fout.open("banking.txt",ios::in|ios::out|ios::binary);
  267. if(!fout)
  268. {
  269. cout<<"FILE OPEN ERROR";
  270. getch();
  271. return;
  272. }
  273. fout.seekg(ios::beg);
  274. cout<<"\n\t\t\tENTER RECORD NUMBER:";
  275. cin>>mrno;
  276. while(fout.read((char*)&obj_6,recsize))
  277. {
  278. if(obj_6.giveaccountno()==mrno)
  279. {
  280. clrscr();
  281. cout<<"\n\n\t\t\tOLD DATA\n";
  282. obj_6.dispdata();
  283. int tmprno=obj_6.giveaccountno()-1;
  284. account obj_7;
  285. cout<<"\n\n\t\t\tENTER NEW DATA\n\n";
  286. obj_7.getdata(tmprno);
  287. char confirm;
  288. cout<<"\n\n\n\n\n\n\n\n\n\t\t\tARE YOU SURE(Y/N) ";
  289. cin>>confirm;
  290. if(confirm=='Y'||confirm=='y')
  291. {
  292. fout.seekg(-1*recsize,ios::cur);
  293. fout.write((char*)&obj_7,recsize);
  294. clrscr();
  295. cout<<"\n\n\n\n\n\n\n\n\n\t\t\tRECORD MODIFIED";
  296. cout<<"\n\t\t\tPress any key to continue.....";
  297. flag=1;
  298. }
  299. }
  300. if(flag==0)
  301. {
  302. clrscr();
  303. cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\tNO SUCH RECORD EXIST\n";
  304. cout<<"\t\t\tPress any key to continue.....\n";
  305. }
  306. }
  307. fout.close();
  308. getch();
  309. }
  310. void withdraw()
  311. {
  312. account obj_9;
  313. fstream fout;
  314. int mrno=0;
  315. int recsize=sizeof(account);
  316. clrscr();
  317. cout<<"\n\n\n\n\n\n\n\n\n\t\t\tWITHDRAWAL MENU";
  318. fout.open("banking.txt",ios::in|ios::out|ios::binary);
  319. if(!fout)
  320. {
  321. cout<<"FILE OPEN ERROR";getch();return;}
  322. fout.seekg(ios::beg);
  323. cout<<"\n\n\t\t\tENTER ACCOUNT NUMBER:";
  324. cin>>mrno;
  325. while(fout.read((char*)&obj_9,recsize))
  326. {
  327. if(obj_9.giveaccountno()==mrno)
  328. {
  329. clrscr();
  330. cout<<"\n\n\n\n\n\n\n\n\n\t\tENTER THE AMOUNT TO BE WITHDRAWN:Php.";
  331. cin>>w;
  332. clrscr();
  333. obj_9.withdrawal(w);
  334. fout.seekg(-1*recsize,ios::cur);
  335. fout.write((char*)&obj_9,recsize);
  336. }
  337. }
  338. fout.close();
  339. getch();
  340. }
  341.  
  342. void deposit(void)
  343. {
  344. account obj_10;
  345. fstream fout;
  346. int mrno=0;
  347. int recsize=sizeof(account);
  348. clrscr();
  349. cout<<"\n\n\n\n\n\n\n\n\n\t\t\tDEPOSITAL MENU\n";
  350. fout.open("banking.txt",ios::in|ios::out|ios::binary);
  351. if(!fout)
  352. {
  353. cout<<"FILE OPEN ERROR";getch();return;}
  354. fout.seekg(ios::beg);
  355. cout<<"\n\t\t\tENTER ACCOUNT NUMBER:";
  356. cin>>mrno;
  357. while(fout.read((char*)&obj_10,recsize))
  358. {
  359. if(obj_10.giveaccountno()==mrno)
  360. {
  361. clrscr();
  362. cout<<"\n\n\n\n\n\n\n\n\n\t\tENTER THE AMOUNT TO BE DEPOSITED:Php.";
  363. cin>>w;
  364. clrscr();
  365. obj_10.deposital(w);
  366. fout.seekg(-1*recsize,ios::cur);
  367. fout.write((char*)&obj_10,recsize);
  368. }
  369. }
  370. fout.close();
  371. getch();
  372. }
Last edited by jayli27; Mar 6th, 2009 at 9:33 am. Reason: add code tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jayli27 is offline Offline
8 posts
since Mar 2009
Mar 6th, 2009
0

Re: how to conert this to stdio.h and conio.h

If you want to convert that to C language then replace cout with printf() statements, fout with FILE, seeg() with fseek(), etc.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005
Mar 6th, 2009
0

Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.

what about the cin???
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jayli27 is offline Offline
8 posts
since Mar 2009
Mar 6th, 2009
0

Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.

scanf()

Have a quick read over a basic C tutorial
Last edited by Freaky_Chris; Mar 6th, 2009 at 10:20 am.
Reputation Points: 325
Solved Threads: 118
Master Poster
Freaky_Chris is offline Offline
702 posts
since Apr 2008
Mar 6th, 2009
0

Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.

what about others...
plss help me about my program..
i had less info in converting iostream to stdio...
would you edit this code and then repost with an stdio.h and conio.h format..
i would really appreciate...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jayli27 is offline Offline
8 posts
since Mar 2009
Mar 6th, 2009
0

Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.

I'm too lazy.
Reputation Points: 325
Solved Threads: 118
Master Poster
Freaky_Chris is offline Offline
702 posts
since Apr 2008
Mar 6th, 2009
0

Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.

ah ok..

by the way thanks....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jayli27 is offline Offline
8 posts
since Mar 2009
Mar 6th, 2009
0

Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.

someone pls!!!

i really need some help...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jayli27 is offline Offline
8 posts
since Mar 2009
Mar 6th, 2009
0

Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.

i hope someone will help me and repost my program that is already in some stdio and conio format. or just post what will be replaced and what will i replace. thnk you..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jayli27 is offline Offline
8 posts
since Mar 2009
Mar 6th, 2009
1

Re: how to convert this to stdio.h and conio.h.convert the cout to printf and etc.

If you keep bumping your thread unnecessarily, I'll close it. Be patient and if someone wants to help, they'll help.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: SSE alligned allocation inside struct
Next Thread in C++ Forum Timeline: slotmachine reel spin simulation





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC