Thread: Undefined symbol 'stdprn'

  1. #1
    Unregistered
    Guest

    Undefined symbol 'stdprn'

    can anyone tell me why im getting this error Undefined symbol 'stdprn' in this code...because stdprn is defined in stdio.h i think?
    i get the error on line 161 and 190
    Code:
    #include <stdio.h>        /*   fread, fwrite, printf, fprintf, fopen, fclose   */
    #include <stdlib.h>                                   /*   rand, srand, exit   */
    #include <time.h>                                                  /*   time   */
    #include <conio.h>                                        /*   getch, getche   */
    
    #define SCREENHEADER()   for (i = 0; i < 4; i++)printf("D1 D2 D3 TOT ");\
                             printf("D1 D2 D3 TOT\n");\
                             for (i = 0; i < 4; i++)\
                                 printf("---------+---");\
                             printf("--------\n")
    #define PRINTHEADER()   for (i = 0; i < 4; i++)\
                                fprintf(stdprn, "D1 D2 D3 TOT ");\
                            fprintf(stdprn, "D1 D2 D3 TOT\n");\
                            for (i = 0; i < 4; i++)\
                                fprintf(stdprn, "-------+-");\
                            fprintf(stdprn, "------\n")
    
    #define CLS()   printf("\033[2J")
    
    struct dice
      {
        int die[3];                                 /*   résultats des trois dés   */
        int sum;                                              /*   total par jet   */
      };
    
    void restoscreen(struct dice *d, int *f);         /*   affichage du fichier   */
    void restoprn(struct dice *d, int *f);           /*   impression du fichier   */
    void freqtoscreen(int *f);           /*   affiche les fréquences des totaux   */
    void freqtoprint(int *f);            /*   imprime les fréquences des totaux   */
    int brand(int p, int q);      /*   crée des nombres aléatoires entre p et q   */
    
    main()
    {
       FILE *fp;
       struct dice res[1000];                           /*   résultats des jets   */
       struct dice zero = {0};                      /*   pour initialiser "res"   */
       int i, k, rep1, rep2, rep3, rep4;             /*   variables de contrôle   */
       int h;                                           /*   tampon pour totaux   */
       int freq[19];                                 /*   fréquences des totaux   */
       long sec;                                         /*   heure en secondes   */
       char filename[81];                        /*   nom du fichier d'archives   */
    
       do
       {
         printf("Le programme simule 1.000 jets de trois dés.");
         time(&sec);                           /*   récupère l'heure en secondes   */
         srand((unsigned) sec);                          /*   initialise "rand"   */
         for (i = 0; i < 1000; i++)    /*   initialise le tableau des résultats   */
            res[i] = zero;
         for (i = 0; i < 19; i++)   /*   initialise le tableau des fréquences   */
            freq[i] = 0;
         for (i = 0; i < 1000; i++)   /*   remplissage du tableau des résultats   */
             {
               for (k = 0; k < 3; k++)
                  res[i].die[k] = brand(1,6);   /* crée un nombre aléatoire entre 1 et 6   */
               h = res[i].sum = res[i].die[0] + res[i].die[1] + res[i].die[2];
               freq[h] = freq[h] + 1;                   /* compte les fréquences   */
             }
         printf("\nTerminé. Archivage des résultats ? (o/n)");
         rep1 = getche();
         if (rep1 == 'o')
            {
              printf("\nNom du fichier : ");
              gets(filename);
              if ((fp = fopen(filename, "w")) == NULL)
                 {
                   fprintf(stderr, "Erreur en écriture sur fichier %s\n", filename);
                   exit(1);
                 }
    
       /* écriture du tableau dans le fichier   */
    
              fwrite(res, sizeof(struct dice), 1000, fp);
              fclose(fp);
              printf("\nRésultats enregistrés dans fichier %s.\n", filename);
              printf("Affichage du fichier ?"
              "(e = écran   i = imprimante   n = pas d'affichage)\n");
              switch (rep2 = getche())
                {
                  case 'e':
                  case 'i':
                  if ((fp = fopen(filename, "r")) == NULL)
                     {
                       fprintf(stderr, "Erreur d'ouverture sur fichier %s\n", filename);
                       exit(2);
                     }
    
       /*   lecture du fichier   */
    
                  fread(res, sizeof(struct dice), 1000, fp);
                  if (rep2 == 'e')                               /* sortie écran   */
                    restoscreen(res, freq);
                  else                                      /* sortie imprimante   */
                    restoprn(res, freq);
                  fclose(fp);
                  break;
                  default: ;
                }                                               /*   fin switch   */
            }                                        /*   fin if rep1 == "o"   */
         else                                         /*   pas de fichier créé   */
           {
             printf("\nAfficher les résultats ? (o/n)");
             rep3 = getche();
             if (rep3 == 'o')
                restoscreen(res, freq);
           }
    
         printf("\n1000 autres jets ? (o/n)");
         rep4 = getche();
    
       } while (rep4 == 'o');
    }
    
    void restoscreen(struct dice *d, int *f)           /*   affiche les données   */
    {
       int i;                                          /*   pour SCREENHEADER()   */
       int n, linecount = 0;
       SCREENHEADER();
       for (n = 0; n < 1000; n++)
         {
           printf(" %d  %d  %d  %2d",
                    d[n].die[0], d[n].die[1], d[n].die[2], d[n].sum);
    
           if (((n+1)%5) == 0)                        /*   5 résultats par ligne   */
             {
               printf("\b\b \n");
               linecount++;
             }
           if ((((linecount+1)%21) == 0) && n != 999)
    	{
    	   printf("\n\n<Entr‚e> pour page suivante.");
       	   getch();
               CLS();
               SCREENHEADER();
               linecount = 0;
             }
         }
       freqtoscreen(f);             /*   affiche la distribution des fréquences   */
    }
    
    
    void freqtoscreen(int *f)       /*   affiche la distribution des fréquences   */
    {
       int i;
       printf("\nLes totaux des tirages ont les fréquences suivantes : \n");
       printf("Total :    ");
       for (i = 3; i < 19; i++)
          printf("%4d ", i);
       printf("\nFréquence :");
       for (i = 3; i < 19; i++)
          printf("%4d", f[i]);
       printf("\n");
    }
    
    
    void restoprn(struct dice *d, int *f)              /*   imprime les données   */
    {
       int i;                                           /*   pour PRINTHEADER()   */
       int n, columns = 0, linecount = 0, pagecount = 0;
       printf("\nIMPRESSION DU FICHIER ...\n");
       PRINTHEADER();
       for (n = 0; n < 1000; n++)
         {
         ++columns;
         fprintf(stdprn, " %d  %d  %d  %2d ",
         d[n].die[0], d[n].die[1], d[n].die[2], d[n].sum);
         if (columns == 4)
           {
             n++;
             fprintf(stdprn, " %d  %d  %d  %2d\n",
             d[n].die[0], d[n].die[1], d[n].die[2], d[n].sum);
             linecount++;
             columns = 0;
           }
         if ((((linecount+1)%61) == 0) && n != 999)
           {
             fprintf(stdprn, "\n\n\t\t\t      - page %d - ", ++pagecount);
             fprintf(stdprn, "\n\n\n\f");                        /* saut de page   */
         PRINTHEADER();
         linecount = 0;
           }
         }
       freqtoprint(f);              /*   imprime la distribution des fréquences   */
    }
    
    
    void freqtoprint(int *f)        /*   imprime la distribution des fréquences   */
    {
       int i;
       fprintf(stdprn, "\n Les totaux des tirages ont les fréquences suivantes : ");
       fprintf(stdprn, "\nTotal :     ");
       for (i = 3; i < 19; i++)
         fprintf(stdprn, "%4d", i);
       fprintf(stdprn, "\nFréquence :");
       for (i = 3; i < 19; i++)
         fprintf(stdprn, "%4d", f[i]);
    }
    
    
    int brand(int p, int q)       /*   crée des nombres aléatoires entre p et q   */
    {
       return (p + (rand() % (q-p+1)));
    }
    oh and im using windows xp and borland C++ 5.01 if it can help...

  2. #2
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    Both stdprn and stdaux are undefined for Win32 apps. sorry.

    From what I've read, both of those are old DOS commands, used for 16 bit systems and the like. It looks like you're going to have to find a way around it.

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    There are plenty of posts on this forum about using fopen() to access the printer..... you might get lucky and find one that fits your needs.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Unregistered
    Guest
    ok thanks for your help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM