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

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2009
Posts: 8
Reputation: jayli27 is an unknown quantity at this point 
Solved Threads: 0
jayli27 jayli27 is offline Offline
Newbie Poster

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

 
0
  #1
Mar 6th, 2009
  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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,378
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1466
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

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

 
0
  #2
Mar 6th, 2009
If you want to convert that to C language then replace cout with printf() statements, fout with FILE, seeg() with fseek(), etc.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 8
Reputation: jayli27 is an unknown quantity at this point 
Solved Threads: 0
jayli27 jayli27 is offline Offline
Newbie Poster

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

 
0
  #3
Mar 6th, 2009
what about the cin???
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 670
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

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

 
0
  #4
Mar 6th, 2009
scanf()

Have a quick read over a basic C tutorial
Last edited by Freaky_Chris; Mar 6th, 2009 at 10:20 am.
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 8
Reputation: jayli27 is an unknown quantity at this point 
Solved Threads: 0
jayli27 jayli27 is offline Offline
Newbie Poster

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

 
0
  #5
Mar 6th, 2009
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...
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 670
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

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

 
0
  #6
Mar 6th, 2009
I'm too lazy.
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 8
Reputation: jayli27 is an unknown quantity at this point 
Solved Threads: 0
jayli27 jayli27 is offline Offline
Newbie Poster

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

 
0
  #7
Mar 6th, 2009
ah ok..

by the way thanks....
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 8
Reputation: jayli27 is an unknown quantity at this point 
Solved Threads: 0
jayli27 jayli27 is offline Offline
Newbie Poster

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

 
0
  #8
Mar 6th, 2009
someone pls!!!

i really need some help...
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 8
Reputation: jayli27 is an unknown quantity at this point 
Solved Threads: 0
jayli27 jayli27 is offline Offline
Newbie Poster

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

 
0
  #9
Mar 6th, 2009
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..
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,625
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 716
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

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

 
1
  #10
Mar 6th, 2009
If you keep bumping your thread unnecessarily, I'll close it. Be patient and if someone wants to help, they'll help.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC