Oppure

Loading
09/08/08 12:34
paul90
ciao a tutti!
ho un grande problema, anzi due.
Ho scaricato un programmino molto semplice giusto per un primo approccio al C.
Il problema sarebbe che appena faccio compilare il codice (utilizzo dev c++) ricevo questo errore:
[Linker error] undefined reference to `window'
[Linker error] undefined reference to `bioskey'

Qualcuno mi potrebbe aiutare?se volete il codice chiedete...

grazie!
aaa
11/08/08 10:00
lorenzo
posta il codice e in che punto del programma viene dato errore...
aaa
11/08/08 12:07
paul90
ecco il codice:


#include <stdio.h>
#include <windows.h>
#include <conio.h>
#include <conio.c>

#include <stdlib.h>
//Definizione di costanti di comodo

#define UP	328
#define DOWN	336
#define LEFT	321
#define RIGHT	333
#define CR	13
#define ESC	27
#define DEL	339
#define TAB	9
#define BSP	8

  struct persona{                  	   //Definizione di un tipo struttura
     char nome[30];
     char cognome[30];
     char indirizzo[100];
     char telefono[20];
     };

  struct persona amico; 	    //amico è una variabile di tipo persona

      int getkey(void);
      void closewin(int x1,int y1,int x2,int y2);
      void inverte();
      void printat(int x,int y, char s1[]);
      void schermo();
      void cancella(int a[10][100]);
      void message(char st1[]);
      void campi_protetti(int a[10][100],int x0, int y0,
		     int max_len, int max_voci,
	           char voce_1[30], char voce_2[30], 
                 char voce_3[30], char voce_4[30]);




//PROGRAMMA PRINCIPALE

   int main()
   {

   #define testo_titolo "  CAMPI PROTETTI"

   int  cmd, lt, i ,j;
   int a[10][100]; 		  //Matrice che contiene la scheda di input

   inverte();		//	Inverte i colori dello sfondo e del testo
   schermo();
   cancella(a); 			                // Inizializza la matrice a

   message(" <Esc> Inserisci  ");		   // Messaggio a fondo schermo

campi_protetti(a,20,10,40,4, "Cognome", "Nome", "Indirizzo",  
               "Telefono");


 				        // Trasferimento della matrice a in amico

   for(i=0;i<=20;i++)amico.cognome[i]=a[1][i+1];
   for(i=0;i<=20;i++)amico.nome[i]=a[2][i+1];
   for(i=0;i<=40;i++)amico.indirizzo[i]=a[3][i+1];
   for(i=0;i<=20;i++)amico.telefono[i]=a[4][i+1];

   closewin(28,3,75,7); 	  //  Preparazione finestra per stampa dati
   window(28,3,75,7);
   printat(1,1," Scheda utente inserita"); 	    //Stampa della scheda 
                                                       //       inserita
   gotoxy(1,2);
   cprintf("%s", amico.cognome);
   gotoxy(1,3);
   cprintf("%s", amico.nome);
   gotoxy(1,4);
   cprintf("%s", amico.indirizzo);
   gotoxy(1,5);
   cprintf("%s", amico.telefono);

   message(" <Esc> Esci  ");

   getch();

   return 0;

     }

//FINE PROGRAMMA PRINCIPALE

     void printat(int x,int y, char s1[])			  //  Scrive un msg
     {
     gotoxy(x,y);cprintf("%s",s1);}

     void message(char st1[])		     	//Scrive un msg a fondo schermo
     {closewin(2,25,78,25);gotoxy(2,25);cprintf(st1);}

     int lunghezza_stringa(char s[])	   // Calcola la lunghezza di s
     {int i;
     i=0;while(s[i]!='ecco il codice:



#include <stdio.h>
#include <windows.h>
#include <conio.h>
#include <conio.c>

#include <stdlib.h>
//Definizione di costanti di comodo

#define UP	328
#define DOWN	336
#define LEFT	321
#define RIGHT	333
#define CR	13
#define ESC	27
#define DEL	339
#define TAB	9
#define BSP	8

  struct persona{                  	   //Definizione di un tipo struttura
     char nome[30];
     char cognome[30];
     char indirizzo[100];
     char telefono[20];
     };

  struct persona amico; 	    //amico è una variabile di tipo persona

      int getkey(void);
      void closewin(int x1,int y1,int x2,int y2);
      void inverte();
      void printat(int x,int y, char s1[]);
      void schermo();
      void cancella(int a[10][100]);
      void message(char st1[]);
      void campi_protetti(int a[10][100],int x0, int y0,
		     int max_len, int max_voci,
	           char voce_1[30], char voce_2[30], 
                 char voce_3[30], char voce_4[30]);




//PROGRAMMA PRINCIPALE

   int main()
   {

   #define testo_titolo "  CAMPI PROTETTI"

   int  cmd, lt, i ,j;
   int a[10][100]; 		  //Matrice che contiene la scheda di input

   inverte();		//	Inverte i colori dello sfondo e del testo
   schermo();
   cancella(a); 			                // Inizializza la matrice a

   message(" <Esc> Inserisci  ");		   // Messaggio a fondo schermo

campi_protetti(a,20,10,40,4, "Cognome", "Nome", "Indirizzo",  
               "Telefono");


 				        // Trasferimento della matrice a in amico

   for(i=0;i<=20;i++)amico.cognome[i]=a[1][i+1];
   for(i=0;i<=20;i++)amico.nome[i]=a[2][i+1];
   for(i=0;i<=40;i++)amico.indirizzo[i]=a[3][i+1];
   for(i=0;i<=20;i++)amico.telefono[i]=a[4][i+1];

   closewin(28,3,75,7); 	  //  Preparazione finestra per stampa dati
   window(28,3,75,7);
   printat(1,1," Scheda utente inserita"); 	    //Stampa della scheda 
                                                       //       inserita
   gotoxy(1,2);
   cprintf("%s", amico.cognome);
   gotoxy(1,3);
   cprintf("%s", amico.nome);
   gotoxy(1,4);
   cprintf("%s", amico.indirizzo);
   gotoxy(1,5);
   cprintf("%s", amico.telefono);

   message(" <Esc> Esci  ");

   getch();

   return 0;

     }

//FINE PROGRAMMA PRINCIPALE

     void printat(int x,int y, char s1[])			  //  Scrive un msg
     {
     gotoxy(x,y);cprintf("%s",s1);}

     void message(char st1[])		     	//Scrive un msg a fondo schermo
     {closewin(2,25,78,25);gotoxy(2,25);cprintf(st1);}

     int lunghezza_stringa(char s[])	   // Calcola la lunghezza di s
     {int i;
     i=0;while(s[i]!='{parsed_message}') i++;
     return i;    }

     void inverte()				 //Inverte lo sfondo e il testo
     {

     window(1,1,80,25);textbackground(WHITE);textcolor(BLACK);
     clrscr();}

     void closewin(int x1,int y1,int x2,int y2)	   // Chiude una finestra
     {textbackground(WHITE);
     textcolor(BLACK);window(x1,y1,x2,y2);clrscr();
     textbackground(WHITE);textcolor(BLACK);window(1,1,80,25);}

     void openwin(int x1,int y1,int x2,int y2)	//	Apre una finestra
     {textbackground(BLACK);textcolor(GREEN);
     window(x1,y1,x2,y2);clrscr();}

     void screenview()					     // Disegna il quadro
     {
     int j,x0,x1,y0,y1;
     x0=1;y0=1;x1=80;y1=24;
     printat(x0,y0,"?");
     for(j=1;j<=x1-2;j++) cprintf("?");cprintf("?");
     for(j=1;j<=y1-4;j++){printat(x0,y0+j,"?");
     gotoxy(x0+x1-1,y0+j);cprintf("?");}
     printat(x0,y0+y1-4,"?");
     for(j=1;j<=x1-2;j++) cprintf("?");cprintf("?");
     printat(x0,y0+y1-3,"?");printat(x0+x1-1,y0+y1-3,"?");
     printat(x0,y0+y1-2,"?");printat(x0+x1-1,y0+y1-2,"?");
     printat(x0,y0+y1-1,"?");
     for(j=1;j<=x1-2;j++) cprintf("?");printat(x0+x1-1,y0+y1+1,"?");}

     void schermo()		     	             // Scrive l'intestazione
     {int n;
     n=lunghezza_stringa(testo_titolo);
     clrscr(); screenview();
     gotoxy(40-n/2,1); cprintf(testo_titolo);  }

     int getkey(void)	  //Legge dal buffer di tastiera il tasto battuto
     {int key, lo, hi;
     key = bioskey(0);
     lo = key & 0X00FF;
     hi = (key & 0XFF00) >> 8;
     return((lo == 0) ? hi + 256 : lo); }

     void cancella(int a[10][100])		     	    //Cancella la matrice
     {int i,j;
     for(i=0;i<10;i++){for(j=0;j<100;j++)a[i][j]= ' ';}}

     int alfa_numerico(int lt)	//	Il carattere è alfanumerico ?
     {int n;
     n=0;
     if((lt>=91)&&(lt<=122)) n=-1;
     if((lt>=32)&&(lt<=63 )) n=-1;
     if((lt>=65)&&(lt<=90))  n=-1;
     if(n==0) return lt;else return n;
     }

    void campi_protetti(int a[10][100],int x0, int y0,
	int max_len, int max_voci,
	char voce_1[30], 
      char voce_2[30], 
      char voce_3[30], 
      char voce_4[30])
    {int lt,cmd;
    window(3,y0,23,y0+4);
    gotoxy(1,1);
    cprintf("%s",voce_1);
    gotoxy(1,2);
    cprintf("%s",voce_2);
    gotoxy(1,3);
    cprintf("%s",voce_3);
    gotoxy(1,4);
    cprintf("%s",voce_4);
    window(1,1,80,25);
    openwin(x0,y0,x0+max_len,y0+max_voci-1);
    gotoxy(1,1);
    while(1==1) {
     lt=getkey();
     cmd=alfa_numerico(lt);
     switch(cmd)   {
     case ESC:   window(1,1,80,25);return;
     case CR:	   gotoxy(1,wherey()+1);break;
     case TAB:   gotoxy(1,wherey()+1);break;
     case LEFT:  gotoxy(wherex()-1,wherey());break;
     case RIGHT: gotoxy(wherex()+1,wherey());break;
     case UP:    gotoxy(wherex(),wherey()-1);break; 
     case DOWN:  gotoxy(wherex(),wherey()+1);break;
     case BSP:   gotoxy(wherex()-1,wherey());putchar(' ');
		     a[wherey()][wherex()]=' ';
	   gotoxy(wherex()-1,wherey());break;
     case -1:    if(wherex()<=max_len){
 		     putchar(lt);
                 a[wherey()][wherex()]=lt;}break;   }       }
}




ogni volta che viene usato window() e bioskey() mi viene rimandato errore..:-|') i++; return i; } void inverte() //Inverte lo sfondo e il testo { window(1,1,80,25);textbackground(WHITE);textcolor(BLACK); clrscr();} void closewin(int x1,int y1,int x2,int y2) // Chiude una finestra {textbackground(WHITE); textcolor(BLACK);window(x1,y1,x2,y2);clrscr(); textbackground(WHITE);textcolor(BLACK);window(1,1,80,25);} void openwin(int x1,int y1,int x2,int y2) // Apre una finestra {textbackground(BLACK);textcolor(GREEN); window(x1,y1,x2,y2);clrscr();} void screenview() // Disegna il quadro { int j,x0,x1,y0,y1; x0=1;y0=1;x1=80;y1=24; printat(x0,y0,"?"); for(j=1;j<=x1-2;j++) cprintf("?");cprintf("?"); for(j=1;j<=y1-4;j++){printat(x0,y0+j,"?"); gotoxy(x0+x1-1,y0+j);cprintf("?");} printat(x0,y0+y1-4,"?"); for(j=1;j<=x1-2;j++) cprintf("?");cprintf("?"); printat(x0,y0+y1-3,"?");printat(x0+x1-1,y0+y1-3,"?"); printat(x0,y0+y1-2,"?");printat(x0+x1-1,y0+y1-2,"?"); printat(x0,y0+y1-1,"?"); for(j=1;j<=x1-2;j++) cprintf("?");printat(x0+x1-1,y0+y1+1,"?");} void schermo() // Scrive l'intestazione {int n; n=lunghezza_stringa(testo_titolo); clrscr(); screenview(); gotoxy(40-n/2,1); cprintf(testo_titolo); } int getkey(void) //Legge dal buffer di tastiera il tasto battuto {int key, lo, hi; key = bioskey(0); lo = key & 0X00FF; hi = (key & 0XFF00) >> 8; return((lo == 0) ? hi + 256 : lo); } void cancella(int a[10][100]) //Cancella la matrice {int i,j; for(i=0;i<10;i++){for(j=0;j<100;j++)a[i][j]= ' ';}} int alfa_numerico(int lt) // Il carattere è alfanumerico ? {int n; n=0; if((lt>=91)&&(lt<=122)) n=-1; if((lt>=32)&&(lt<=63 )) n=-1; if((lt>=65)&&(lt<=90)) n=-1; if(n==0) return lt;else return n; } void campi_protetti(int a[10][100],int x0, int y0, int max_len, int max_voci, char voce_1[30], char voce_2[30], char voce_3[30], char voce_4[30]) {int lt,cmd; window(3,y0,23,y0+4); gotoxy(1,1); cprintf("%s",voce_1); gotoxy(1,2); cprintf("%s",voce_2); gotoxy(1,3); cprintf("%s",voce_3); gotoxy(1,4); cprintf("%s",voce_4); window(1,1,80,25); openwin(x0,y0,x0+max_len,y0+max_voci-1); gotoxy(1,1); while(1==1) { lt=getkey(); cmd=alfa_numerico(lt); switch(cmd) { case ESC: window(1,1,80,25);return; case CR: gotoxy(1,wherey()+1);break; case TAB: gotoxy(1,wherey()+1);break; case LEFT: gotoxy(wherex()-1,wherey());break; case RIGHT: gotoxy(wherex()+1,wherey());break; case UP: gotoxy(wherex(),wherey()-1);break; case DOWN: gotoxy(wherex(),wherey()+1);break; case BSP: gotoxy(wherex()-1,wherey());putchar(' '); a[wherey()][wherex()]=' '; gotoxy(wherex()-1,wherey());break; case -1: if(wherex()<=max_len){ putchar(lt); a[wherey()][wherex()]=lt;}break; } } }


ogni volta che viene usato window() e bioskey() mi viene rimandato errore..:-|
aaa
12/08/08 8:55
lorenzo
prova ad includere

#include<bios.h>


quel tipo di errore indica che la funzione che chiami non è stata definita
aaa
12/08/08 11:31
paul90
Ho provato includendo il file bios.h
e come avevo gia' provato mi esce questo errore:
4 C:\..\index.c
bios.h: No such file or directory.


:(
aaa
18/08/08 18:22
lorelapo
:ot: : non pensi che dovresti iniziare con qualcosa di più tradizionale per capirci, tipo chenne sò un Hello, World !
aaa
18/08/08 18:34
paul90
no grazie, nn ho bisogno dei tuoi suggerimenti.
Ho solo bisogno di risolvere questo problema.
aaa
18/08/08 21:23
lorelapo
1 : I Consigli sono sempre utili

2 : Il tuo problema può essere dovuto al fatto che
a) Non hai linkato le librerie necessarie
b) Non hai tutti i file necessari (header e source)
c) Le definizioni delle funzioni provocano problemi di genere
d) Le funzioni che segnali non esistono da nessuna parte nei file

Se tu avessi seguito un percorso normale saresti arrivato a questo programma con conoscenze sufficenti a risolvere il problema da solo, comunque se aggiungi particolari dovrei poterti aiutare meglio non mi sembra un gran problema, il linker fa spesso di questi scherzi.
Ultima modifica effettuata da lorelapo 18/08/08 21:29
aaa