Tengo un problema con este codigo
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
#include <stdio.h>
FILE *doc;
using namespace std;
int His();
int Cien();
int Depor();
int Geo();
int c=1;
int main()
{
int s,tot,u=0;
srand(time(NULL));
while (c==1)
{
system ("cls");
cout<<"Presione cualquier tecla para escoger su categoria"<<endl;
getch();
s=rand()% 4 + 1;
switch (s)
{
case 1:
{
His();
break;
}
case 2:
{
Cien();
break;
}
case 3:
{
Depor();
break;
}
case 4:
{
Geo();
break;
}
}
}
system ("pause");
return 0;
}
int His()
{
int x,i=1,w;
system ("cls");
cout<<"<===============Su categoria es Historia===============>"<<endl;
cout<<"Presione cualquier tecla para escoger su pregunta"<<endl;
getch();
doc = fopen("C:\Users\HERNAN\Desktop\prueba.txt","r");
while(i<=5)
w=getc(doc);
if (w =='\n') printf ("\n");
else
printf("%c",w);
fclose(doc);
return 0;
}
int Depor()
{
int x,i=1,w;
system ("cls");
cout<<"<===============Su categoria es Ciencia===============>"<<endl;
cout<<"Presione cualquier tecla para escoger su pregunta"<<endl;
getch();
doc = fopen("C:\Users\HERNAN\Desktop\prueba.txt","r");
while(i<=5)
w=getc(doc);
if (w =='\n') printf ("\n");
else
printf("%c",w);
fclose(doc);
return 0;
}
int Cien()
{
int x,i=1,w;
system ("cls");
cout<<"<===============Su categoria es Deportes===============>"<<endl;
cout<<"Presione cualquier tecla para escoger su pregunta"<<endl;
getch();
doc = fopen("C:\Users\HERNAN\Desktop\prueba.txt","r");
while(i<=5)
w=getc(doc);
if (w =='\n') printf ("\n");
else
printf("%c",w);
fclose(doc);
return 0;
}
int Geo()
{
int x,i=1,w;
system ("cls");
cout<<"<===============Su categoria es Geografia===============>"<<endl;
cout<<"Presione cualquier tecla para escoger su pregunta"<<endl;
getch();
doc = fopen("C:\Users\HERNAN\Desktop\prueba.txt","r");
while(i<=5)
w=getc(doc);
if (w =='\n') printf ("\n");
else
printf("%c",w);
fclose(doc);
return 0;
}
El problema en la ejecución es este
[MOD] para publicar código, usa la etiqueta GeShi correspondiente. Gracias.
Debes poner titulos descriptivos del tema, "Ayuda!" no lo es, leete las Reglas del Foro.