ndeniche 402 Posting Virtuoso Featured Poster

so, all i have to do to use a c library is copy the *.c file into the directory where i have my .cpp and call it in the program with an #include "*.c" ?

ndeniche 402 Posting Virtuoso Featured Poster

i've inferred somewhere out there how to use fork() o c, but the program i'm running is in c++... so i would loooove to know if there is something similar in c++

ndeniche 402 Posting Virtuoso Featured Poster

i have to create a perent/children process in c++... is there any way to do it as in c?

ndeniche 402 Posting Virtuoso Featured Poster

did you try to run the program i posted? i mean, the second one... because when i run it, when it asks me for the first input (and by input i mean about data entry), i cannot see what i'm writing, and the program slows down completely... i don't know if it is because of the compiler i'm using (bloodshed dev-cpp) or what...

anyway, i'm still stuck in there...

ndeniche 402 Posting Virtuoso Featured Poster

thnx for your help. now, this library (windows.h) is completely new for me so i did what i understood was right, and the program runs almost to perfection...

i have already adapted the source code you gave me to my program. Though, now it presents a new problem... the inputs are not running like they should, i have turned all of the text to engish so you can understand what is the purpose of the program.

#include <iostream.h>
#include <stdio.h>
#include "conio.c"
#include <time.h>
#include <Windows.h>

int end=0;
DWORD WINAPI user_input_function(LPVOID iValue);

main(){
   HANDLE hThread1;
   DWORD dwGenericThread;
   hThread1=CreateThread(NULL,0,user_input_function,NULL,0,&dwGenericThread);
   const float flow = 0.1549;
   const float super = 2.42;
   const float regular = 2.31;
   const float diesel = 1.86;
   char carb[30],comb,sure[30];
   float timer;
   time_t sec, diff;
   do{
      cout<<"\n                 Welcome to the gas station\n";
      cout<<"\n\nEnter the kind of fuel you want to buy\n\n-->";
      cin>>carb;
      comb=carb[0];
      while (!((comb=='s')||(comb=='S')||(comb=='d')||(comb=='D')||(comb=='r')||(comb=='R'))){
         cout<<"\n\nThe entered fuel is invalid.\n\aPlease enter it again\n\n-->";
         cin>>carb;
         comb=carb[0];
      }do{
         cout<<"Are you sure you want to buy ";
         if ((comb=='s')||(comb=='S')) printf("Super?\n\n-->");
         if ((comb=='r')||(comb=='R')) printf("Regular?\n\n-->");
     if ((comb=='d')||(comb=='D')) printf("Diesel?\n\n-->");
         cin>>sure;
         if (!((sure[0]=='s')||(sure[0]=='S')||(sure[0]=='n')||(sure[0]=='N'))) printf("\nLa respuesta ingresada es incorrecta\n\aPor favor Ingrese SI o NO\n");
      }while (!((sure[0]=='s')||(sure[0]=='S')||(sure[0]=='n')||(sure[0]=='N')));
   }while ((sure[0]=='n')||(sure[0]=='N'));
   if ((comb=='s')||(comb=='S')) printf("\n\nSuper actually costs $3.4f/Galon\n\n", super);
   if ((comb=='r')||(comb=='R')) printf("\n\nRegular actually costs $%3.4f/Galon\n\n", regular);
   if ((comb=='d')||(comb=='D')) printf("\n\nDiesel actually costs $%3.4f/Galon\n\n", diesel);
   cout<<"\n         Press >>ENTER<< to start dispensing the fuel\n"; 
   diff = clock();
   getchar();
   getchar();
   system("cls");
   while (end==0){
      sec = clock() - diff;
      timer=float(sec)/1000;
      gotoxy(15,4);
      if ((comb=='s')||(comb=='S')) printf("Super-->");
      if ((comb=='r')||(comb=='R')) printf("Regular-->");
      if ((comb=='d')||(comb=='D')) printf("Diesel-->");
      gotoxy(28,4);
      printf("%3.4f",timer*flow);
      gotoxy(15,5);
      printf("Dollar-->");
      gotoxy(28,5); …
ndeniche 402 Posting Virtuoso Featured Poster

Hi...
I have been trying to figure this out, but it has been an impossible task 4 me...:rolleyes:
this is a gasoline pump counter, and i have developed an infinite cycle to print the gas counter and the cash counter...:mrgreen: the problem is, i need a stopper for the cycle, where the idea is that the user stops the flow of gas by pressing ENTER... but i'm done with trying everything to do this...:mad:

The lines are in spanish, but they are just junk...:cool:

Please help me... i'd really appreciate that...:)

Here's the code: