472,119 Members | 1,595 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Atm machine program in C

Hello everyone I am a student who is in big trouble. I have a ATM machine program that i need to write in C but the problem is that my teacher wants us to use file IO and he didnt teach us how to use it. below is my program. I am desperately begging for help.


Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. int main()
  4. {
  5.    char  option,pin,transaction;
  6.    int deposit, withdraw;
  7.    option='0';
  8.  
  9.  
  10.  
  11.     printf("WELCOME TO SAMUEL'S BANK\n");
  12.     printf("------------------------------\n\n");
  13.     printf("Main Menu\n");
  14.     printf("------------------------------\n");
  15.     printf("1)Enter Pin #\n");
  16.     printf("2)Exit\n");
  17.     printf("------------------------------\n\n");
  18.     scanf("%c", &option);
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.         {
  26.             system ("cls");
  27.             printf("Pin Number Verification\n");
  28.             printf("------------------------------\n\n");
  29.             printf("Please enter your pin number: ");
  30.             scanf("%s", &pin);
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.             //if(inputfile ==NULL)
  39.             {
  40.                 printf("Unable to open input file\n");
  41.             }
  42.             return 1;
  43.  
  44.  
  45.             system ("cls");    
  46.             printf("Transactions\n");
  47.             printf("------------------------------\n");
  48.             printf("1)Deposit\n2)Withdraw\n3)Statement\n4)Exit\n");
  49.             printf("------------------------------\n");
  50.             scanf("%s",&transaction);
  51.         }
  52.  
  53.  
  54.  
  55.  
  56.                     if (transaction =='1')
  57.  
  58.                         {
  59.                             system ("cls");
  60.                             printf("Deposit\n");
  61.                             printf("------------------------------\n\n");
  62.                             printf("Please enter the amount of money you would like to deposit: ");
  63.                             scanf("%d", &deposit);
  64.                     }
  65.  
  66.                     if (transaction =='2')
  67.  
  68.                         {
  69.                             system ("cls");
  70.                             printf("Withdraw\n");
  71.                             printf("------------------------------\n\n");
  72.                             printf("Please enter the amount of money you would like to withdraw: ");
  73.                             scanf("%d", &withdraw);
  74.                         }
  75.  
  76.                     if (transaction=='3')
  77.  
  78.                         {
  79.                             system ("cls");
  80.                             printf("Statement\n");
  81.                             printf("------------------------------\n\n");
  82.                         }
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90. return 0;
  91.  
  92.  
  93. }
Nov 30 '08 #1
8 27750
gpraghuram
1,275 Expert 1GB
But what help u need?
File IO means you want to get the input/ouput from a file instead of STDIO?

Raghu
Dec 1 '08 #2
Yes sir but the problem is hat i do not konw how to use file io so i wanted to get help with it.
Dec 1 '08 #3
I was not properly thought how to use file io so i wanted help with it becaue we have to use arrays with teh file io too.
Dec 1 '08 #4
weaknessforcats
9,208 Expert Mod 8TB
Are you able to get this working using arrays?

Next write a function to load your arrays. Pass in the array addresses and have the function install hard-coded values.

Next, get the program working. You just call the function to load the hard-coded values into the arrays.

After the program is working, replace the guts of the funciton with logic that reads a disc file and stores the data in the arrays.
Dec 1 '08 #5
Hey first of all i would like to thank you for responding. I would like to ask you if you had an example of arrays because i wasnt properly thought on how to use it.
Dec 2 '08 #6
weaknessforcats
9,208 Expert Mod 8TB
There is an article named Arrays Revealed in the C/C++ HowTos that containes exactly what you want.

Unfortunuately, due to a recent site upgrade the HowTos are not working right now.

I tried to attach it to this post but it is too large.
Dec 2 '08 #7
weaknessforcats
9,208 Expert Mod 8TB
Wouldn't you know that five minutes after I said the articel on arrays in unavailable, I found it.

Here it is: http://bytes.com/insights/c/772412-arrays-revealed.
Dec 2 '08 #8
Thank you so much. You are a real life saver.
Dec 2 '08 #9

Post your reply

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

Similar topics

13 posts views Thread by Adrian Parker | last post: by
4 posts views Thread by Denise Mills | last post: by
3 posts views Thread by Nidhee Pathak via .NET 247 | last post: by
6 posts views Thread by Michael | last post: by
reply views Thread by joestevens232 | last post: by

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.