Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
bucle que ejecuta un tiempo infinito después de llamar a la función de visualización
do { printf("1 :Enter Company Deatils\n"); printf("2 :Display stoke Deatils\n"); printf("0 :Exit\n"); printf("\nEnter num: "); scanf("%d", &n); switch (n) { case 1: enter(); break; case 2: display(); break; } } while (n != 0);

Cuando ingreso 2 para llamar a la función de visualización después de que scanf() no tome ninguna entrada y ejecute el ciclo por tiempo infinito.

 void display_d(){ point c1; FILE *fptr; fptr = fopen("company_det.txt","r"); while(fread(&c1,sizeof(point),1,fptr)){ printf("\n%s %s %d\n",c1.company_name,c1.bla.date,c1.bla.price); } fclose(stdin); }

esta es mi función de visualización

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

La función display_d() cierra stdin . Cuando la función regrese, scanf intentará usar stdin para leer otro dígito. Este es un comportamiento indefinido ( ver respuestas aquí ).

Probablemente quiso cerrar el archivo en lugar de stdin .

Además, se debe verificar el valor de retorno de fopen . Será NULL si fopen no pudo abrir el archivo.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!