I have this program and I need help with 2 issues
It needs a way to save the information for thr[acct] and timesave[acct]. I need a way to save the information so it can be used later. I know I am supposed to write another file for it to store and pull from but I do not know how to go about it.
It needs a way to read a square wave signal from a specified USB and it needs a way to send a output signal high or low to the USB. I have been looking around but I have not found a way to go about it.
Any help with this would be greatly appreciated.
#include <stdio.h>
#include <stdlib.h>
void accountselect();
int timesave[20]={0};
int thr[20]={0};
int p; int p1;
int tvon;
void accountselect()
{
int input=0;
printf( "Enter your Account Number, 0 to quit: " );
scanf( "%d", &input );
switch ( input ) {
case 1-19:
workoutbegin(input);
break;
case 0:
printf( "Thanks for using exervision\n" );
break;
default:
printf( "Bad input, quitting!\n" );
break;
}
getch();
}
void accountset()
{
int age;
char sex;
int acct=1;
printf( "Please enter your age: ");
scanf( "%d", &age );
printf("please enter your gender (m/f): ");
sex=getch();
sex=getch();
if (sex=='f' ) {
thr[acct]=226-age;
}
else if (sex=='m') {
thr[acct] = 220-age;
}
else {
printf( "invalid entry\n" );
}
printf ("Your target heart rate is %d\n" ,thr[acct] );
printf("Your account number is %d. Please remember this number for future use.\n",acct);
system("Pause");
}
void account()
{
int input;
printf( "1. Run Exervision\n" );
printf( "2. Create account\n" );
printf( "3. quit\n" );
printf( "Selection: " );
scanf( "%d", &input );
switch ( input ) {
case 1:
accountselect();
break;
case 2:
accountset();
break;
case 3:
printf( "Thanks for using exervision\n" );
break;
default:
printf( "Bad input, quitting!\n" );
break;
}
getchar();
}
int workoutbegin(int acct)
{
printf("start working out\n");
printf("work out if you wish to stop watching TV and save any time left press q");
p1=p;
system("ping -n 60 127.0.0.1");
if (p >thr[acct])
{
tvon=1;
timesave[acct]++;
p1=p;
printf("Congradulations in Target Heart Rate zone. You earned 1 minute extra time that you can save or use at the end of your work out/n");
workoutbegin(acct);
}
else if (p > p1)
{
tvon=1;
printf("You may continue to watch tv, but you are not yet in your Target Heart Rate zone.\n");
p1 =p;
workoutbegin(acct);
}
else if (p0)
{
tvon=1;
timesave[acct]--;
p1 =p;
printf("You are watching on borrowed time. Time is being taken from your savings.\n");
workoutbegin(acct);
}
else if (p
{
printf ("YOU'RE NOT WORKING OUT HARD ENOUGH. WORK OUT HARDER OR THE TV WILL TURN OFF IN ONE MINUTE!\n");
system("ping -n 60 127.0.0.1");
if (p<p1)>
printf ("Sorry workout was inefficient and you are out of saved time. No TV for you.\n");
tvon=0;
}
}
int main(int argc, char *argv[])
{
account();
return 0;
system("PAUSE");
}
[EDIT]
Added tags for code formatting. Even in the unedited version some text at p and p1 conditions is wrong (probably destroyed when pasting).
[/EDIT]