| | |
function problem
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2008
Posts: 60
Reputation:
Solved Threads: 0
Hi!
I've made this program, but not working
First time I compiled it with MicrosoftC++ and gave me just 1 error, that corrected, then compiled it with DevC++ as teacher used it, and started giving me a lot of errors
that some of them dont know how to correct them

Thanks in advanced
I've made this program, but not working
First time I compiled it with MicrosoftC++ and gave me just 1 error, that corrected, then compiled it with DevC++ as teacher used it, and started giving me a lot of errors
that some of them dont know how to correct them

Thanks in advanced

C++ Syntax (Toggle Plain Text)
#include <cstdlib> #include <iostream> using namespace std; struct art { char name [50]; char branch [50]; float PrecioVenta; float PrecioCosto; int stock; void load_art(float &price, char name, char branch, float &PrecioVenta, float &PrecioCosto, int &stock); void CambiarStock(int &stock); void ConsultarPrecioCosto(char name[], float PrecioCosto); void ConsultarPrecioVenta(char name[], float PrecioVenta); void mostrar(char name[], float price, char branch[], float PrecioVenta, float PrecioCosto, int stock); }; struct StockGeneral { art datos[100]; char encontrado; int pos; char NombreBuscado[100]; StockGeneral(); void BuscarStock(char NombreBuscado[], int &pos, char &encontrado); float CambiarPrecioVenta (float PrecioVenta); void CargarStockGeneral(); void CompraArticulos(); void MostrarStock(); }; struct client { char name[50]; int id; char domicilio [100]; float precio_acumulado; void CargarDatos(int &id, char nombre[], char domicilio[], float &precio_acumulado); void MostrarDatos(int id, char nombre[], char domicilio[], float precio_acumulado); void ConsultarSaldo(); void ActualizarSaldo(int id, float &precio_acumulado); }; struct total_clients { client datos[100]; int tope; void CargarTotalClientes(); void MostrarTotalClientes(); void BuscarTotalClientes(char NombreBuscado[],int &pos, char &encontrado); }; struct venta { void CargarFactura(char name[], char branch[], int &stock, float &totalfactura); void MostrarFactura (char name[], char branch[], int &stock, float totalfactura); } //---------------------------------- // // ART - FUNCIONES // //---------------------------------- void art::load_art(float &price, char name, char branch, float &PrecioVenta, float &PrecioCosto, int &stock) { art article; cout << " ------------------------------------- \n\n"; cout << " CARGA DATOS DEL ARTICULO: \n"; cout << " ------------------------------------- \n\n"; cout<< " Nombre: "; cin.getline(article.name, 50); cout << " Marca: "; cin.getline(article.branch, 50); cout << " Precio Venta: "; cin >> article.PrecioVenta; cout << " Precio Costo: "; cin >> article.PrecioCosto; cout << " Stock: "; cin >> article.stock; } void art::CambiarStock (int &stock) { art article; cout << " Ingrese el nombre del articulo: "; cin.getline(article.name, 50); cout << " Ingresar nuevo stock: "; cin >> article.stock; } void art::ConsultarPrecioCosto (char name[], float PrecioCosto) { art article; cout << " Ingrese el nombre del articulo: "; cin.getline(article.name, 50); cout << " El precio es: " << article.PrecioCosto; } void art::ConsultarPrecioVenta (char name[], float PrecioVenta) { art article; cout << " Ingrese el nombre del articulo: "; cin.getline(article.name, 50); cout << " El precio es: " << article.PrecioVenta; } void art::mostrar(char name[], float price, char branch[], float PrecioVenta, float PrecioCosto, int stock) { art article; cout << " -------------------------------------------------------------- \n"; cout << " -------------------------- ARTICULO --------------------------"; cout << " -- Nombre: " << article.name << "\n"; cout << " -- Marca: " << article.branch << "\n"; cout << " -- Precio de Venta: " << article.PrecioVenta << "\n"; //EXPECTED ; BEFORE "ARTICLE" cout << " -- Precio de Costo: " << article.PrecioCosto << "\n"; cout << " -- Stock: " << article.stock << "\n"; // EPECTED ; BEFORE "ARTICLE" cout << " -------------------------------------------------------------- \n"; } //---------------------------------- // // STOCK - FUNCIONES // //---------------------------------- StockGeneral::StockGeneral() { int tope[100]; for (int i =0; i <100; i++) tope[i]=0; } void StockGeneral::CargarStockGeneral() { art article; char rta; int tope; while (tope<100) { do { datos[pos].load_art(price, name[], branch, PrecioVenta, PrecioCosto, stock); tope++; cout << " Cargar otro? S/N?"; cin >> rta; cin.ignore(); } while(rta != 'n' && rta!='N'); system("CLS"); } } void StockGeneral::BuscarStock(char NombreBuscado[],int &pos, char &encontrado) { art article; encontrado=0; pos=0; int tope=100; int i=0; while ((pos < tope) && (strcmp(NombreBuscado, article.name)!=0)) { pos++; if (pos<tope) encontrado=1; else pos=1; } } float StockGeneral::CambiarPrecioVenta (float PrecioVenta) { char encontrado; art article; cout << " Ingrese el nombre del articulo: "; cin.getline(article.name, 50); StockGeneral.BuscarStock(NombreBuscado[], pos, encontrado); if (encontrado==0) { cout << " Ingresar precio de costo del articulo: "; cin >> PrecioVenta; } else if (encontrado == 1) cout << " No se puede cambiar el precio. \n El articulo ingresado no existe. \n\n"; return PrecioVenta; } void StockGeneral::CompraArticulos() { char NombreBuscado[100], encontrado; int stockaux, pos; cout << " Escribir nombre de articulo a cambiar stock: "; cin.getline(NombreBuscado, 100); StockGeneral.BuscarStock(NombreBuscado[], pos, encontrado); if (encontrado==0) { cout << " Ingresar stock del articulo a comprar: "; cin >> stockaux; datos[pos].stock += stockaux; cout << " Se actualizo el stock.-"; } else if (encontrado == 1) cout << " No se puede cambiar el precio. \n El articulo ingresado no existe. \n\n"; } void StockGeneral::MostrarStock() { art articulo; cout << " ------------------------------------------------------------------- \n"; cout << " -------------------------- STOCK GENERAL -------------------------- \n"; cout << " ------------------------------------------------------------------- \n"; for (int i=0; i <100; i++) articulo.mostrar(name[], branch[], PrecioVenta, PrecioCosto, stock); cout << " ------------------------------------------------------------------- \n"; cout << " ------------------------------------------------------------------- \n"; cout << " ------------------------------------------------------------------- \n"; } //---------------------------------- // // CLIENTE - FUNCIONES // //---------------------------------- void client::CargarDatos(int &id, char nombre[], char domicilio[], float &precio_acumulado) { client cliente; cout << " INGRESO DE DATOS DEL CLIENTE: \n"; cout << " ------------------------------------- \n\n"; cout << " Codigo: "; cin >> cliente.id; cout << " Nombre: "; cin.getline (cliente.name,50); cout << " Domicilio: "; cin.getline (cliente.domicilio,100); cout << " Saldo Acumulado: "; cin >> cliente.precio_acumulado; } void client::MostrarDatos(int id, char nombre[], char domicilio[], float precio_acumulado) { client cliente; cout << " -+-+-+- DATOS DEL CLIENTE -+-+-+- \n"; cout << " ---------------------------------------------------- \n\n\n"; cout << " --- ID:" << cliente.id << " \n"; cout << " --- Nombre: " << cliente.name << " \n"; cout << " --- Domicilio: " << cliente.domicilio << "\n"; cout << " --- Saldo: " << cliente.precio_acumulado << "\n"; cout << " ---------------------------------------------------- \n\n\n"; } void client::ConsultarSaldo() { client cliente; cout << " Ingrese ID del cliente: "; cin >> cliente.id; cout << " El saldo es " << cliente.precio_acumulado << " \n"; } void client::ActualizarSaldo(int id, float &precio_acumulado) { client cliente; float nuevosaldo; cout << " Ingresar ID del cliente: "; cin >> cliente.id; cout << " Ingrese nuevo Saldo: "; cin >> nuevosaldo; cliente.precio_acumulado = nuevosaldo; } //---------------------------------- // TOTAL DE CLIENTES // // FUNCIONES //---------------------------------- void total_clients::CargarTotalClientes() { char rta; while (tope<100) { do { datos[tope].CargarDatos(); tope++; cout << " Cargar otro? S/N?"; cin >> rta; cin.ignore(); } while(rta != 'n' && rta!='N'); system("CLS"); } } void total_clients::MostrarTotalClientes() { client cliente; int id; char name [50], domicilio [100]; float precio_acumulado; cout << " DETALLE DE TODOS LOS CLIENTES: \n"; cout << " ------------------------------------------------- \n\n"; cliente.MostrarDatos(id, name, domicilio, precio_acumulado); cout << " ------------------------------------------------- \n\n"; } void total_clients::BuscarTotalClientes(char NombreBuscado[],int &pos, char &encontrado) { art article; encontrado=0; pos=0; int tope=100; while ((pos <tope) && (strcmp(NombreBuscado, article[pos].name)!=0)) { pos++; if (pos<tope) encontrado=true; else pos=1; } } //---------------------------------- // FACTURAS // // FUNCIONES //---------------------------------- void venta::CargarFactura(char name[], char branch[], int &stock, float totalfactura) { art articulo; int stockfactura; float totalfactura; cout << " Ingresar nombre de articulo a vender: "; cin.getline(articulo.name, 50); StockGeneral.BuscarStock(NombreBuscado, pos, encontrado); if (encontrado == 1) { cout << " Ingresar marca: "; cin.getline(articulo.branch,50); cout << " Ingresar stock: "; cin >> stockfactura; while (stockfactura > articulo.stock) { cout << " No se puede vender esa cantidad. \n Ingresar stock correcto: "; cin >> stockfactura; } } articulo.stock = articulo.stock - stockfactura; totalfactura= stockfactura*articulo.PrecioVenta; cout << " Ingresar nombre de cliente: "; cin.getline (client.name, 50); total_clients.BuscarCliente(NombreBuscado, pos, encontrado); if (encontrado == 1) { client.precio_acumulado = client.precio_acumulado - totalfactura; if (client.precio_acumulado < 0) cout << " No se puede realizar esta venta."; } else if (encontrado ==0) cout << " El cliente ingresado no existe. \n"; } void venta::MostrarFactura(char name[], char branch[], int &stock, float totalfactura) { cout << " ---------------------------------------------------- "; cout << " -- Articulo: " << art.name << "\n"; cout << " -- Marca: " << art.branch << "\n"; cout << " -- Stock vendido: " << art.stock << "\n\n"; cout << " -- Cliente: " << client.name << "\n"; cout << " -- Saldo actual del cliente: " << client.precio_acumulado << "\n\n\n"; cout << " ---------- TOTAL FACTURA: -- $" << totalfactura << "\n"; } //---------------------------------- // // MAIN // //---------------------------------- int main() { art articulos; StockGeneral StockTotal; client clientes; total_clients todoslosclientes; venta factura; float totalfactura; int stock; char choice; cout << " ------------------------------------------- \n"; cout << " -------------- ELEGIR ACCION -------------- \n"; cout << " ------------------------------------------- \n\n"; cout << " -1- Cargar articulos. \n"; // LLAMA A CARGAR DEL STOCKGENERAL cout << " -2- Consultar Precio de Costo. \n"; cout << " -3- Consultar Precio de Venta. \n"; cout << " -4- Cambiar Stock. \n"; cout << " -5- Mostrar articulos. \n\n"; // MOSTRAR DEL STOCKGENERAL cout << " -6- Buscar un articulo. \n"; cout << " -7- Comprar articulos. \n"; cout << " -8- Mostrar StockGeneral. \n\n"; cout << " -9- Cargar datos del cliente. \n"; cout << " -a- Consultar Saldo. \n"; cout << " -b- Actualizar saldo. \n"; cout << " -c- Buscar Cliente. \n"; cout << " -d- Mostrar clientes. \n\n"; cout << " -h- Cargar datos para factura. \n"; cout << " -i- Mostrar factura. \n\n"; cout << " -0- Salir. \n\n"; cout << " Elegiste: "; cin >> choice; cout << " ------------------------------------------- \n\n"; cout << " ------------------------------------------- \n\n"; cout << " ------------------------------------------- \n\n"; switch (choice) { case '1': StockTotal.CargarStockGeneral(); break; case '2': articulo.consultarprecosto(); break; case '3': articulo.consultarprevta(); break; case '4': articulo.cambiarcosto(); break; case '5': StockTotal.MostrarStock(); break; case '6': StockTotal.BuscarStock(NombreBuscado[], pos, encontrado); break; case '7': StockTotal.CompraArticulos(); break; case '8': StockTotal.MostrarStock(); break; case '9': todoslosclientes.CargarTotalClientes(); break; case 'a': case 'A': clientes.ConsultarSaldo(); break; case 'b':case 'B': clientes.ActualizarSaldo(); break; case 'c': case 'C': todoslosclientes.BuscarTotalClientes(); break; case 'd': case 'D': todoslosclientes.MostrarTotalClientes(); break; case 'h': case 'H': factura.CargarFactura(name[], branch[], stock, totalfactura); break; case 'i': case 'I': factura.MostrarFactura(); break; case'0': cout << " ---Fin del programa--- \n"; } system("PAUSE"); return EXIT_SUCCESS; }
>>First time I compiled it with MicrosoftC++ and gave me just 1 error, that corrected
You should have tried to compile it again with that compiler. I used VC++ 2008 Express and the code you posted had billions of error messages.
There are indeed several errors.
1) struct art -- you should make that a class, not a struct. Yes they are nearly the same thing but its customary to call it a class when it has methods. Same with struct venta.
2) you forgot the semicolon at the end of struct venta
Lots of other problems that you need to fix.
You should have tried to compile it again with that compiler. I used VC++ 2008 Express and the code you posted had billions of error messages.
There are indeed several errors.
1) struct art -- you should make that a class, not a struct. Yes they are nearly the same thing but its customary to call it a class when it has methods. Same with struct venta.
2) you forgot the semicolon at the end of struct venta
Lots of other problems that you need to fix.
Last edited by Ancient Dragon; Jul 20th, 2009 at 10:41 am.
•
•
Join Date: Jul 2008
Posts: 60
Reputation:
Solved Threads: 0
Hi!
I corrected the errors it was giving me, but now, when i try to create a new client makes a loop after the client's address and doesnt go out
and the other thing is that when try to create new client, doesnt let me not to create another client.
and this is more like a logical question: in the function "void BuscarStock(char NombreBuscado[], int &pos, char &encontrado);" and the ones look like it, doesnt really look for what they should look for.
dont knowwhat im doing wrong with it
thanks in advanced
I corrected the errors it was giving me, but now, when i try to create a new client makes a loop after the client's address and doesnt go out

and the other thing is that when try to create new client, doesnt let me not to create another client.
and this is more like a logical question: in the function "void BuscarStock(char NombreBuscado[], int &pos, char &encontrado);" and the ones look like it, doesnt really look for what they should look for.
dont knowwhat im doing wrong with it

thanks in advanced

C++ Syntax (Toggle Plain Text)
#include <cstdlib> #include <iostream> using namespace std; struct art { char name [50]; char branch [50]; float PrecioVenta; float PrecioCosto; int stock; void load_art(float &price, char name[], char branch[], float &PrecioVenta, float &PrecioCosto, int &stock); void CambiarStock(int &stock); void ConsultarPrecioCosto(char name[], float PrecioCosto); void ConsultarPrecioVenta(char name[], float PrecioVenta); void mostrar(char name[], float price, char branch[], float PrecioVenta, float PrecioCosto, int stock); }; struct StockGeneral { art datos[100]; char encontrado; int pos; char NombreBuscado[100]; StockGeneral(); void BuscarStock(char NombreBuscado[], int &pos, char &encontrado); float CambiarPrecioVenta (float PrecioVenta); void CargarStockGeneral(); void CompraArticulos(); void MostrarStock(); }; struct client { char name[50]; int id; char domicilio [100]; float precio_acumulado; void CargarDatos(int &id, char nombre[], char domicilio[], float &precio_acumulado); void MostrarDatos(int id, char nombre[], char domicilio[], float precio_acumulado); void ConsultarSaldo(); void ActualizarSaldo(int id, float &precio_acumulado); }; struct total_clients { client datos[100]; int tope; void CargarTotalClientes(); void MostrarTotalClientes(); void BuscarTotalClientes(char NombreBuscado[],int &pos, char &encontrado); }; struct venta { void venta::CargarFactura(char name[], char branch[], int &stock, float totalfactura); void MostrarFactura (char name[], char branch[], int &stock, float totalfactura); }; //---------------------------------- // // ART - FUNCIONES // //---------------------------------- void art::load_art(float &price, char name[], char branch[], float &PrecioVenta, float &PrecioCosto, int &stock) { art article; cout << " ------------------------------------- \n\n"; cout << " CARGA DATOS DEL ARTICULO: \n"; cout << " ------------------------------------- \n\n"; cout<< " Nombre: "; cin.getline(article.name, 50); cout << " Marca: "; cin.getline(article.branch, 50); cout << " Precio Venta: "; cin >> article.PrecioVenta; cout << " Precio Costo: "; cin >> article.PrecioCosto; cout << " Stock: "; cin >> article.stock; } void art::CambiarStock (int &stock) { art article; cout << " Ingrese el nombre del articulo: "; cin.getline(article.name, 50); cout << " Ingresar nuevo stock: "; cin >> article.stock; } void art::ConsultarPrecioCosto (char name[], float PrecioCosto) { art article; cout << " Ingrese el nombre del articulo: "; cin.getline(article.name, 50); cout << " El precio es: " << article.PrecioCosto; } void art::ConsultarPrecioVenta (char name[], float PrecioVenta) { art article; cout << " Ingrese el nombre del articulo: "; cin.getline(article.name, 50); cout << " El precio es: " << article.PrecioVenta; } void art::mostrar(char name[], float price, char branch[], float PrecioVenta, float PrecioCosto, int stock) { art article; cout << " -------------------------------------------------------------- \n"; cout << " -------------------------- ARTICULO --------------------------"; cout << " -- Nombre: " << article.name << "\n"; cout << " -- Marca: " << article.branch << "\n"; cout << " -- Precio de Venta: " << article.PrecioVenta << "\n"; //EXPECTED ; BEFORE "ARTICLE" cout << " -- Precio de Costo: " << article.PrecioCosto << "\n"; cout << " -- Stock: " << article.stock << "\n"; // EPECTED ; BEFORE "ARTICLE" cout << " -------------------------------------------------------------- \n"; } //---------------------------------- // // STOCK - FUNCIONES // //---------------------------------- StockGeneral::StockGeneral() { int tope[100]; for (int i =0; i <100; i++) tope[i]=0; } void StockGeneral::CargarStockGeneral() { art article; char rta; int tope; float price, PrecioVenta, PrecioCosto; char name[50], branch[50]; int stock; while (tope<100) { do { datos[pos].load_art(price, name, branch, PrecioVenta, PrecioCosto, stock); tope++; cout << " Cargar otro? S/N?"; cin >> rta; cin.ignore(); } while(rta != 'n' && rta!='N'); system("CLS"); } } void StockGeneral::BuscarStock(char NombreBuscado[],int &pos, char &encontrado) { art article; encontrado=0; pos=0; int tope=100; int i=0; while ((pos < tope) && (strcmp(NombreBuscado, article.name)!=0)) { pos++; if (pos<tope) encontrado=1; else pos=1; } } float StockGeneral::CambiarPrecioVenta (float PrecioVenta) { char encontrado; art article; StockGeneral stockdetotales; cout << " Ingrese el nombre del articulo: "; cin.getline(article.name, 50); stockdetotales.BuscarStock(NombreBuscado, pos, encontrado); if (encontrado==0) { cout << " Ingresar precio de costo del articulo: "; cin >> article.PrecioVenta; } else if (encontrado == 1) cout << " No se puede cambiar el precio. \n El articulo ingresado no existe. \n\n"; return PrecioVenta; } void StockGeneral::CompraArticulos() { char NombreBuscado[100], encontrado; int stockaux, pos; StockGeneral stockdetotales; cout << " Escribir nombre de articulo a cambiar stock: "; cin.getline(NombreBuscado, 100); stockdetotales.BuscarStock(NombreBuscado, pos, encontrado); if (encontrado==0) { cout << " Ingresar stock del articulo a comprar: "; cin >> stockaux; datos[pos].stock += stockaux; cout << " Se actualizo el stock.-"; } else if (encontrado == 1) cout << " No se puede cambiar el precio. \n El articulo ingresado no existe. \n\n"; } void StockGeneral::MostrarStock() { art articulo; char name[50], branch[50]; float PrecioVenta, PrecioCosto, price; int stock; cout << " ------------------------------------------------------------------- \n"; cout << " -------------------------- STOCK GENERAL -------------------------- \n"; cout << " ------------------------------------------------------------------- \n"; for (int i=0; i <100; i++) articulo.mostrar(name, price, branch, PrecioVenta, PrecioCosto, stock); cout << " ------------------------------------------------------------------- \n"; cout << " ------------------------------------------------------------------- \n"; cout << " ------------------------------------------------------------------- \n"; } //---------------------------------- // // CLIENTE - FUNCIONES // //---------------------------------- void client::CargarDatos(int &id, char nombre[], char domicilio[], float &precio_acumulado) { client cliente; cout << " INGRESO DE DATOS DEL CLIENTE: \n"; cout << " ------------------------------------- \n\n"; cout << " Codigo: "; cin >> cliente.id; cout << " Nombre: "; cin.getline (cliente.name,50); cin.ignore(); cout << " Domicilio: "; cin.getline (cliente.domicilio,100); cin.ignore(); cout << " Saldo Acumulado: "; cin >> cliente.precio_acumulado; } void client::MostrarDatos(int id, char nombre[], char domicilio[], float precio_acumulado) { client cliente; cout << " -+-+-+- DATOS DEL CLIENTE -+-+-+- \n"; cout << " ---------------------------------------------------- \n\n\n"; cout << " --- ID:" << cliente.id << " \n"; cout << " --- Nombre: " << cliente.name << " \n"; cout << " --- Domicilio: " << cliente.domicilio << "\n"; cout << " --- Saldo: " << cliente.precio_acumulado << "\n"; cout << " ---------------------------------------------------- \n\n\n"; } void client::ConsultarSaldo() { client cliente; cout << " Ingrese ID del cliente: "; cin >> cliente.id; cout << " El saldo es " << cliente.precio_acumulado << " \n"; } void client::ActualizarSaldo(int id, float &precio_acumulado) { client cliente; float nuevosaldo; cout << " Ingresar ID del cliente: "; cin >> cliente.id; cout << " Ingrese nuevo Saldo: "; cin >> nuevosaldo; cliente.precio_acumulado = nuevosaldo; } //---------------------------------- // TOTAL DE CLIENTES // // FUNCIONES //---------------------------------- void total_clients::CargarTotalClientes() { char rta; int id; char nombre[50], domicilio[100]; float precio_acumulado; while (tope<100) { datos[tope].CargarDatos(id, nombre, domicilio, precio_acumulado); cout << " Cargar otro - S/N?"; cin >> rta; while ((rta != 'n') && (rta!='N')) { datos[tope].CargarDatos(id, nombre, domicilio, precio_acumulado); tope++; cout << " Cargar otro - S/N?"; cin >> rta; cin.ignore(); } system("CLS"); } } void total_clients::MostrarTotalClientes() { client cliente; int id; char name [50], domicilio [100]; float precio_acumulado; cout << " DETALLE DE TODOS LOS CLIENTES: \n"; cout << " ------------------------------------------------- \n\n"; cliente.MostrarDatos(id, name, domicilio, precio_acumulado); cout << " ------------------------------------------------- \n\n"; } void total_clients::BuscarTotalClientes(char NombreBuscado[],int &pos, char &encontrado) { art article; encontrado=0; pos=0; int tope=100; while ((pos <tope) && (strcmp(NombreBuscado, article.name)!=0)) { pos++; if (pos<tope) encontrado=true; else pos=1; } } //---------------------------------- // FACTURAS // // FUNCIONES //---------------------------------- void venta::CargarFactura(char name[], char branch[], int &stock, float totalfactura) { art articulo; int stockfactura; StockGeneral stockdetotales; client cliente; total_clients totaldeclientes; char NombreBuscado[50], encontrado; int pos; cout << " Ingresar nombre de articulo a vender: "; cin.getline(articulo.name, 50); stockdetotales.BuscarStock(NombreBuscado, pos, encontrado); if (encontrado == 1) { cout << " Ingresar marca: "; cin.getline(articulo.branch,50); cout << " Ingresar stock: "; cin >> stockfactura; while (stockfactura > articulo.stock) { cout << " No se puede vender esa cantidad. \n Ingresar stock correcto: "; cin >> stockfactura; } } articulo.stock = articulo.stock - stockfactura; totalfactura= stockfactura*(articulo.PrecioVenta); cout << " Ingresar nombre de cliente: "; cin.getline (cliente.name, 50); totaldeclientes.BuscarTotalClientes(NombreBuscado, pos, encontrado); if (encontrado == 1) { cliente.precio_acumulado = cliente.precio_acumulado - totalfactura; if (cliente.precio_acumulado < 0) cout << " No se puede realizar esta venta."; } else if (encontrado ==0) cout << " El cliente ingresado no existe. \n"; } void venta::MostrarFactura(char name[], char branch[], int &stock, float totalfactura) { art article; client cliente; cout << " ---------------------------------------------------- "; cout << " -- Articulo: " << article.name << "\n"; cout << " -- Marca: " << article.branch << "\n"; cout << " -- Stock vendido: " << article.stock << "\n\n"; cout << " -- Cliente: " << cliente.name << "\n"; cout << " -- Saldo actual del cliente: " << cliente.precio_acumulado << "\n\n\n"; cout << " ---------- TOTAL FACTURA: -- $" << totalfactura << "\n"; cout << " ---------------------------------------------------- "; } //---------------------------------- // // MAIN // //---------------------------------- int main() { art articulos; StockGeneral StockTotal; client clientes; total_clients todoslosclientes; venta factura; float precio_acumulado; float PrecioCosto, PrecioVenta; char NombreBuscado[50], branch[50], name[50], encontrado; int id, pos; float totalfactura; int stock; char choice; cout << " ------------------------------------------- \n"; cout << " -------------- ELEGIR ACCION -------------- \n"; cout << " ------------------------------------------- \n\n"; cout << " -1- Cargar articulos. \n"; cout << " -2- Consultar Precio de Costo. \n"; cout << " -3- Consultar Precio de Venta. \n"; cout << " -4- Cambiar Stock. \n"; cout << " -5- Mostrar articulos. \n\n"; cout << " -6- Buscar un articulo. \n"; cout << " -7- Comprar articulos. \n"; cout << " -8- Mostrar StockGeneral. \n\n"; cout << " -9- Cargar datos del cliente. \n"; cout << " -a- Consultar Saldo. \n"; cout << " -b- Actualizar saldo. \n"; cout << " -c- Buscar Cliente. \n"; cout << " -d- Mostrar clientes. \n\n"; cout << " -h- Cargar datos para factura. \n"; cout << " -i- Mostrar factura. \n\n"; cout << " -0- Salir. \n\n"; cout << " Elegiste: "; cin >> choice; cout << " ------------------------------------------- \n\n"; cout << " ------------------------------------------- \n\n"; cout << " ------------------------------------------- \n\n"; system("CLS"); switch (choice) { case '1': StockTotal.CargarStockGeneral(); break; case '2': articulos.ConsultarPrecioCosto(name, PrecioCosto); break; case '3': articulos.ConsultarPrecioVenta(name, PrecioVenta); break; case '4': articulos.CambiarStock(stock); break; case '5': StockTotal.MostrarStock(); break; case '6': StockTotal.BuscarStock(NombreBuscado, pos, encontrado); break; case '7': StockTotal.CompraArticulos(); break; case '8': StockTotal.MostrarStock(); break; case '9': todoslosclientes.CargarTotalClientes(); break; case 'a': case 'A': clientes.ConsultarSaldo(); break; case 'b':case 'B': clientes.ActualizarSaldo(id, precio_acumulado); break; case 'c': case 'C': todoslosclientes.BuscarTotalClientes(NombreBuscado, pos, encontrado); break; case 'd': case 'D': todoslosclientes.MostrarTotalClientes(); break; case 'h': case 'H': factura.CargarFactura(name, branch, stock, totalfactura); break; case 'i': case 'I': factura.MostrarFactura(name, branch, stock, totalfactura); break; case'0': cout << " ---Fin del programa--- \n"; } system("PAUSE"); return EXIT_SUCCESS; }
•
•
Join Date: Jul 2008
Posts: 60
Reputation:
Solved Threads: 0
I just fixed those warnings (didnt appear with dev). Now, thing is: when try to create an article, program wont let me stop creating new stuff, justs keeps on going. dont really know what im doing wrong. 
thanks in advanced

thanks in advanced
C++ Syntax (Toggle Plain Text)
void StockGeneral::CargarStockGeneral() { char rta; int tope =0; float price, PrecioVenta, PrecioCosto; char name[50], branch[50]; int stock; while (tope<100) { do { datos[pos].load_art(price, name, branch, PrecioVenta, PrecioCosto, stock); tope++; cout << " Cargar otro? S/N?"; cin >> rta; cin.ignore(); } while(rta != 'n' && rta!='N'); system("CLS"); } }
Try using Code::Blocks as your IDE, because I'm sure this uses MinGW, which is the Windows port of the GNU C++ Compiler, which is probably the best C++ compiler. Or... you could try installing Ubuntu and run the original compiler. This way, I'm positive you'll get all the errors that are there in your program.
After doing this myself with your program, I see that you're using
After doing this myself with your program, I see that you're using
stdafx.h , which, as far as I'm concerned, is a Windows-specific header file. The compiler didn't even bother showing the other errors. I'd recommend you to rethink the program using Standard C++, and completely rewrite it. Last edited by 23.12.2012; Jul 21st, 2009 at 8:56 pm.
I strongly recommend using The GNU C++ Compiler as your C++ compiler. It comes with every UNIX/Linux machine, including Mac OS X. If you're a Windows user, have a look over MinGW
•
•
Join Date: Oct 2007
Posts: 29
Reputation:
Solved Threads: 0
To answer your question on why the program is not stopping, it is because you have an infinite loop on line 19 where you are using the AND operator
C++ Syntax (Toggle Plain Text)
while(rta != 'n' && rta!='N')
![]() |
Similar Threads
- Recursive Function Problem (C++)
- recursive function problem (Java)
- read from file problem and function problem (C++)
- C - Function Problem On Compile (C)
- Passing an Array to Function Problem (C++)
- class and function problem (C++)
- Function problem (C++)
- Ask Function problem?thanks (C)
- Function Problem. Please help (PHP)
Other Threads in the C++ Forum
- Previous Thread: ARRAYS: how do i put these values in lo-hi order?
- Next Thread: Gtkmm in codeblocks??
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data database delete desktop developer directshow dll download dynamic encryption error file forms fstream function functions game generator getline givemetehcodez google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number output parameter pointer problem program programming project proxy python random read recursion recursive return string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






