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
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:
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
main(){
const float flujo = 0.1549;
const float super = 59.3492;
const float regular = 57.4371;
const float diesel = 48.2738;
char carb[30],comb,seguro[30];
float timer;
time_t seg, resta;
do{
cout<<"\n Bienvenido a la gasolinera LA GRAN ESTAFA\n";
cout<<"\n\nIngrese el tipo de carburante que desea dispensar\n\n-->";
cin>>carb;
comb=carb[0];
while (!((comb=='s')||(comb=='S')||(comb=='d')||(comb=='D')||(comb=='r')||(comb=='R'))){
cout<<"\n\nEl carburante ingresado es invalido\n\aPor favor ingreselo nuevamente\n\n-->";
cin>>carb;
comb=carb[0];
}do{
cout<<"Esta seguro que desea dispensar ";
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>>seguro;
if (!((seguro[0]=='s')||(seguro[0]=='S')||(seguro[0]=='n')||(seguro[0]=='N'))) printf("\nLa respuesta ingresada es incorrecta\n\aPor favor Ingrese SI o NO\n");
}while (!((seguro[0]=='s')||(seguro[0]=='S')||(seguro[0]=='n')||(seguro[0]=='N')));
}while ((seguro[0]=='n')||(seguro[0]=='N'));
if ((comb=='s')||(comb=='S')) printf("\n\nEl Super cuesta actualmente %3.4f Lempiras/Galon\n\n", super);
if ((comb=='r')||(comb=='R')) printf("\n\nLa Regular cuesta actualmente %3.4f Lempiras/Galon\n\n", regular);
if ((comb=='d')||(comb=='D')) printf("\n\nEl Diesel cuesta actualmente %3.4f Lempiras/Galon\n\n", diesel);
system("cls");
cout<<"\n Presione >>ENTER<< para comenzar a dispensar el combustible\n";
resta = clock();
system("cls");
while (!getch()){ //Here's my problem -- here's the beggining of the infinite cycle
seg = clock() - resta;
timer=float(seg)/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*flujo);
gotoxy(15,5);
printf("Lempiras-->");
gotoxy(28,5);
if ((comb=='s')||(comb=='S')) printf("%3.4f",timer*flujo*super);
if ((comb=='r')||(comb=='R')) printf("%3.4f",timer*flujo*regular);
if ((comb=='d')||(comb=='D')) printf("%3.4f",timer*flujo*diesel);
gotoxy(2,8);
cout<<"\n Presione >>ENTER<< nuevamente para detener el flujo de combustible\n";
system("cls");
}//Here's the end of the infinite cycle
cout<<timer;
printf("\n>>Presione >>ENTER<< para salir<<");
getchar();
return 0;
}