elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


  Mostrar Mensajes
Páginas: [1]
1  Programación / Programación C/C++ / Ayuda con este error en c++ undefined reference to `convertiratexto(float)' en: 6 Mayo 2015, 17:07 pm
Buen Dia.

Me encuentro realizando un programa para calcular series, ingresando un numero por teclado, pero me aparece este error que no me deja continuar. el error es este (ccv9L5Du.o:NewFile.cpp:(.text+0x337): undefined reference to `convertiratexto(float)') Agradezco a quien me pueda ayudar comparto el codigo?
Código
  1. #include<iostream>
  2. #include<string>
  3. #include<cmath>
  4. #include<stdlib.h>
  5. #include<stdio.h>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. string convertiratexto(float f);
  11.  
  12.  
  13.  
  14. int main() {
  15. float fact;
  16. float fact2;
  17. int i;
  18. float inv;
  19. float j;
  20. float k;
  21. float num1;
  22. float pot;
  23. float pot2;
  24. float suma;
  25. float sumatoria;
  26. string texto1;
  27. string texto2;
  28. string texto3;
  29. string texto4;
  30. string texto5;
  31. string texto6;
  32. string texto7;
  33. string texto8;
  34. string texto9;
  35. float total1;
  36. float total2;
  37. float total3;
  38. float total4;
  39. float total5;
  40. float total6;
  41. float total7;
  42. float total8;
  43. float total9;
  44. cout << "\nDigite un numero para calcular serie" << endl;
  45. cin >> num1;
  46. texto1 = "";
  47. texto2 = "";
  48. texto3 = "";
  49. texto4 = "";
  50. texto5 = "";
  51. texto6 = "";
  52. texto8 = "";
  53. texto7 = "";
  54. total1 = 0;
  55. total2 = 0;
  56. total3 = 0;
  57. total4 = 0;
  58. total5 = 0;
  59. total6 = 0;
  60. total7 = 0;
  61. total8 = 0;
  62. sumatoria = 0;
  63. inv = num1;
  64. for (i=1;i<=num1;i++) {
  65. fact = 1;
  66. suma = 0;
  67. pot = 0;
  68. if (i==num1) {
  69. texto1 = texto1+(convertiratexto(i)+"^2");
  70. texto2 = texto2+(convertiratexto(i)+"!");
  71. texto3 = texto3+((convertiratexto(i)+"^")+convertiratexto(i));
  72. texto6 = texto6+convertiratexto(i);
  73. texto9 = texto9+((convertiratexto(i)+"^")+convertiratexto(inv));
  74. } else {
  75. texto1 = texto1+(convertiratexto(i)+"^2 +");
  76. texto2 = texto2+(convertiratexto(i)+"! +");
  77. texto3 = texto3+(convertiratexto(i)+"^"+convertiratexto(i)+" +");
  78. texto6 = texto6+(convertiratexto(i)+" +");
  79. texto9 = texto9+(convertiratexto(i)+"^"+convertiratexto(inv)+" +");
  80. }
  81. if (i%2==0 ){
  82. texto4 = texto4+(" +"+convertiratexto(i)+"^"+convertiratexto(i));
  83. } else {
  84. texto4 = texto4+(" -"+convertiratexto(i)+"^"+convertiratexto(i));
  85. }
  86. texto5 = texto5+("("+convertiratexto(i)+"+(");
  87. texto7 = texto7+"(";
  88. texto8 = texto8+"(";
  89. for (j=1;j<=i;j++) {
  90. fact2 = 1;
  91. for (k=1;k<=j;k++) {
  92. fact2 = (fact2*k);
  93. }
  94. fact = (fact*j);
  95. suma = (suma+j);
  96. pot = pot+(pow(i,j));
  97. pot2 = pot+(pow(i,fact2));
  98. fact2 = 0;
  99. if (j==i) {
  100. if (i==num1) {
  101. texto7 = texto7+convertiratexto(i)+"^"+convertiratexto(j)+") ";
  102. texto8 = texto8+convertiratexto(i)+"^!"+convertiratexto(j)+") ";
  103. } else {
  104. texto7 = texto7+convertiratexto(i)+"^"+convertiratexto(j)+") + ";
  105. texto8 = texto8+convertiratexto(i)+"^!"+convertiratexto(j)+") + ";
  106. }
  107. texto5 = texto5+convertiratexto(j)+")) + ";
  108. } else {
  109. texto7 = texto7+convertiratexto(i)+"^"+convertiratexto(j)+"+";
  110. texto8 = texto8+convertiratexto(i)+"^!"+convertiratexto(j)+" +";
  111. texto5 = texto5+convertiratexto(j)+"+";
  112. }
  113. }
  114. total1 = total1+(i*i);
  115. total2 = total2+fact;
  116. total3 = total3+(pow(i,i));
  117. total5 = total5+(i+suma);
  118. total7 = total7+pot;
  119. total8 = total8+pot2;
  120. total9 = total9+(pow(i,inv));
  121. if (i%2==0) {
  122. total4 = total4+(pow(i,i));
  123. } else {
  124. total4 = total4-(pow(i,i));
  125. }
  126. sumatoria = sumatoria+i;
  127. inv = (inv-1);
  128. }
  129. total6 = total2/sumatoria;
  130. cout << "\nSERIE NUMERO 1" << endl;
  131. cout << texto1 << " =" << total1 << endl;
  132. cout << " " << endl;
  133. cout << "\nSERIE NUMERO 2" << endl;
  134. cout << texto2 << " =" << total2 << endl;
  135. cout << " " << endl;
  136. cout << "\nSERIE NUMERO 3" << endl;
  137. cout << texto3 << " =" << total3 << endl;
  138. cout << " " << endl;
  139. cout << "\nSerie NUMERO 4" << endl;
  140. cout << texto4 << " =" << total4 << endl;
  141. cout << " " << endl;
  142. cout << "\nSerie NUMERO 5" << endl;
  143. cout << texto5 << " =" << total5 << endl;
  144. cout << " " << endl;
  145. cout << "\nSERIE NUMERO 6" << endl;
  146. cout << "( " << texto2 << " )/(" << texto6 << " ) =" << total6 << endl;
  147. cout << " " << endl;
  148. cout << "\nSERIE NUMERO 7" << endl;
  149. cout << texto7 << " =" << total7 << endl;
  150. cout << " " << endl;
  151. cout << "\nSERIE NUMERO 8" << endl;
  152. cout << texto8 << " =" << total8 << endl;
  153. cout << " " << endl;
  154. cout << "\nSERIE NUMERO 9" << endl;
  155. cout << texto9 << " =" << total9 << endl;
  156.  
  157.  
  158. return 0;
  159. }
  160.  
  161.  
  162.  
2  Programación / Programación C/C++ / Ayuda con c++ vectores en: 22 Abril 2015, 23:54 pm
Hola Buen Dia.

Tengo un pequeño inconveniente necesito almacenar datos en vectores, inicialmente los estaba almacenando en un .txt ya que se me hizo mucho mas facil de aprender, pero ahora me piden que esos datos que se almacenaban en .txt se almacenen en vectores, para lograr que el programa trabaje con una cantidad N de productos, que sea indicada por el usuario y   para producir las consultas e informes solicitados se utilizarán los métodos de ordenación y búsqueda y me muestre los mismos resultados con el menú de opciones.

no he logrado entender muy bien este tema.

 espero me puedan ayudar con este codigo.

#include<cstdlib>
#include<iostream>
#include<fstream>
#include<string.h>
#include<conio.h>

using namespace std;
void autor();
void registrar();
void datos();
void consultar();
void modificar();
void salir();
void menu();

//Variables-Globales

char nombre[30],codigo[10],existencia[10],color[10],resp[1];
int costo=0, venta=0;
bool encontrado=false;
char buscod[10];
int main(){
    menu();
    return 0;
    system("PAUSE");
}
void menu(){
    int opcion=0;
    do{
       cout<<"\n\n\t\t******************************"<<endl;
        cout<<"\t\t  ..MENU DE OPCIONES.."<<endl;
        cout<<"\t\t******************************"<<endl;
        cout<<"1. Informacion del Autor "<<endl;
        cout<<"2. Registrar Productos "<<endl;
        cout<<"3. Listado de Datos"<<endl;
        cout<<"4. Consultar Registros"<<endl;
        cout<<"5. Salir"<<endl;
        cout<<"...Seleccione Una Opcion... ";
        cin>>opcion;

        switch(opcion){
            case 1:
                autor();
            break;

            case 2:
                registrar();
            break;

            case 3:
                datos();
            break;

            case 4:
                consultar();
            break;

            case 5:
                salir();
            break;
           
            default:
                cout<<"¡Opcion Incorrecta! selecione nuevamente"<<endl;
        }
    }while(opcion!=5);
}
void autor(){
       cout<<"\n\n\t\t\tINFORMACION DEL AUTOR"<<endl;;
       cout<<"\nAndru rodriguez"<<endl;;
       cout<<"Cod.1234567890"<<endl;;
       cout<<"Estudiante "<<endl;;
       cout<<"xxxxxxxxxxxx@xxxx.xxx"<<endl;;
}
      
void registrar(){
    ofstream archivo;
    archivo.open("productos.txt",ios::out|ios::app);
    if(archivo.is_open()){
        cout<<"\t\tDigite el Nombre del Producto: ";
        cin>>nombre;
        cout<<"\t\tIngresa el Codigo del producto: ";
        cin>>codigo;
        cout<<"\t\tIngresa la Existencia actual del  Producto: ";
        cin>>existencia;
        cout<<"\t\tIngresa el Color del Producto: ";
        cin>>color;
        cout<<"\t\tIngresa el Costo de compra del Producto: ";
        cin>>costo;
        cout<<"\t\tIngresa el Valor para la Venta del Producto: ";
        cin>>venta;
        archivo<<nombre<<" "<<codigo<<" "<<existencia<<" "<<color<<" "<<costo<<" "<<venta<<endl;
    }else{
        cout<<"Error, el Archivo No se Pudo Abrir"<<endl;
    }
    archivo.close();
}

void datos(){
    ifstream lectura;
    lectura.open("productos.txt",ios::out|ios::in);
    if(lectura.is_open()){
        cout<<"\n\n\t\t\tREGISTROS DEL PRODUCTO INGRESADO"<<endl;
        cout<<"**.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.**"<<endl;
        lectura>>nombre;
        while(!lectura.eof()){
            lectura>>codigo;
            lectura>>existencia;
            lectura>>color;
            lectura>>costo;
            lectura>>venta;
            cout<<"Nombre: "<<nombre<<endl;
            cout<<"Codigo: "<<codigo<<endl;
            cout<<"Existencia: "<<existencia<<endl;
            cout<<"Color Disp: "<<color<<endl;
            cout<<"Costo Compra: "<<costo<<endl;
            cout<<"Valor para Venta: "<<venta<<endl;
            lectura>>nombre;
            cout<<"**.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.**"<<endl;
        }
    }else{
        cout<<"Error, el Archivo No se Pudo Abrir, No ha sido creado"<<endl;
    }
    lectura.close();
}

void consultar(){
    ifstream lectura;//variable de tipo lectura
    lectura.open("productos.txt",ios::out|ios::in);//Abrir archivo.txt
   
    if(lectura.is_open()){
        cout<<"Digitar el Codigo del Producto que desea Buscar: ";
        cin>>buscod;
        lectura>>nombre;
        encontrado=false;
        while(!lectura.eof()){
            lectura>>codigo>>existencia>>color>>costo>>venta;
           
            if(strcmp(buscod,codigo)==0){
               cout<<"\n\t\t\tCONSULTA DE PRODUCTOS INGRASADOS"<<endl;
                cout<<"**.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*..*.*.**"<<endl;
                cout<<"Nombre: "<<nombre<<endl;
                cout<<"Codigo: "<<codigo<<endl;
                cout<<"Existencia: "<<existencia<<endl;
                cout<<"Color Disp: "<<color<<endl;
                cout<<"Costo Compra: "<<costo<<endl;
                cout<<"Valor para Venta: "<<venta<<endl;
                cout<<"**.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*..*.*.**"<<endl;
                encontrado=true;
            }
            lectura>>nombre;
        }
        if(encontrado==false){
            cout<<"No hay registros con el codigo ingresado "<<buscod<<endl;
        }
    }else{
        cout<<"No se pudoAbrir el Archivo, aun no ha sido Creado"<<endl;
    }
    lectura.close();
}

void salir(){
   cout<<"\n\n\t\t****                         ****"<<endl;
   cout<<"\n\n\t\t\tPrograma Finalizado"<<endl;
    cout<<"\n\n\t\t\t  Hasta Pronto"<<endl;
    cout<<"\n\n\t\t****                         ****"<<endl;
}
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines