Visualizzazione dei risultati da 1 a 7 su 7
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2010
    Messaggi
    26

    [C] errore incompatible types in assignment

    salve a tutti...in questo programma mi dà un errore alla riga 57, che non riesco a risolvere..mi dice incompatible types in assignment..come posso risolvere?

    codice:
    #include <stdio.h>
    #define DIMENSIONE_VETTORE 20
    typedef enum {FALSE, TRUE} BOOLEAN;
    typedef char String[20];
    typedef struct {int identificatori; String stringhe;} StringPool;
    StringPool sp[DIMENSIONE_VETTORE];
    int add (int identifier, String str);
    int main()
    {
        int identificatore,valore_sentinella,i;
        String stringa;
        
        for(i=0;i<DIMENSIONE_VETTORE;i++)
        sp[i].identificatori = -1;
        
        valore_sentinella = 1;
        
        while(valore_sentinella == 1){
                                                            
        printf("Inserire identificatore: ");
        scanf("%n", &identificatore);
        
        printf("/n");
        
        printf("Inserire stringa: ");
        scanf("%s", &stringa);
        
        printf("/n");
        
        if(add(identificatore, stringa) == TRUE)
        printf("Inserimento riuscito.../n");
        else
        printf("Inserimento errato.../n");
        
        printf("Continuare con l'inserimento? (premere 1 per SI / premere 0 per NO ");
        scanf("%d", &valore_sentinella); }
        
        system("pause");
        return 0;
    }
        
        
        
        
        
    int add (int identifier, String str)
    {    
    
        int i; 
        
        if(identifier > 0 && str!=""){
        for(i=0;i<DIMENSIONE_VETTORE;i++){
        if(identifier == sp[i].identificatori) return FALSE;
        else for(i=0;i<DIMENSIONE_VETTORE;i++){
             if(sp[i].identificatori == -1){
             sp[i].identificatori = identifier;
             sp[i].stringhe = str; }}} 
             else return FALSE; }
    }

  2. #2
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,462
    Scusa, qual è la riga 57 ??
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  3. #3
    Utente di HTML.it
    Registrato dal
    Jan 2010
    Messaggi
    26
    scusate mi ero dimenticata, l'ho segnata in rosso^^

  4. #4
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,462
    Non si copiano le stringhe in questo modo ... in C si usa la funzione strcpy ...
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  5. #5
    Utente di HTML.it
    Registrato dal
    Jan 2010
    Messaggi
    26
    va bene provo ad usare quella e vedo come va..

  6. #6
    Utente di HTML.it
    Registrato dal
    Jan 2010
    Messaggi
    26
    ha funzionato quella ^^

  7. #7
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,462
    Originariamente inviato da annam90
    ha funzionato quella ^^
    Beh ... meno male :-)
    No MP tecnici (non rispondo nemmeno!), usa il forum.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.