Bonjour,
Je créé un programme pour un scanner de code barre. Dans ce programme je déclare char* mais quand je compile le compilateur me dit szData undefined et je ne sais pas pourquoi.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <synlib.h>
//#include "..\include\8000lib.h"
 
int main(void)
{
	UploadData(2);
}
 
BOOL UploadData (int nPort)
    {
    int       i, j, fd, param[10];
    long      k;
    unsigned  sum;
    BYTE      Header [2];
    BYTE      c;
	BYTE *OtherMsg[100]
	char *ACK, *NAK;
	ACK='ACK';
	NAK='NAK';
	int szData[10];
 
 
 
//    if (nPort > 3)
//        return WedgeUpload ();                // Keyboard Wedge
    ConnectingPage ();
//    if (nPort == 1)
//        SetCommType (1, 0);                   // direct 232
//    else 
	if (nPort == 2)
        SetCommType (1, 2);                   // IR
    else 
//	if (nPort == 3)
        SetCommType (1, 3);                   // IrDA
 
//    if (nPort == 3)
        nPort = 1;                            // must use COM2
 
     switch (param[0])
          {
          case '1':   c = 0x08; break;            // 115200,N,8,1
          case '2':   c = 0x0a; break;            // 57600
          case '3':   c = 0x0b; break;            // 38400
          case '4':   c = 0x0c; break;            // 19200
          case '5':   c = 0x0d; break;            // 9600
          }
    open_com (nPort, c);
 
ReTry:
 
    i = 0;
    while (i < 10)
        {
        if (read_com (nPort, (char *)&c))     // if successful reading
            szData [i++] = c;
 
        if (c == '\r')
            break;
 
        if ((c = getchar()) == KEY_ESC)
            {
            close_com (nPort);
            clr_scr ();
            return false;
            }
        }
    szData [i] = 0;
 
    if (!strcmp (szData, "READ\r"))
        {
        write_com (nPort, ACK);
        while (!com_eot (nPort));
        DispString (0, 1, OtherMsg [4], 0);      // Sending data...
        DispString (0, 3, OtherMsg [5], 0);      // Transfered:
        }
    else
        {
        write_com (nPort, NAK);
        while (!com_eot (nPort));
        goto ReTry;
        }
 
    k = 0;
 
	fd = open ("Data");
 
    lseek (fd, 0L, 1);             // 4.10+ move to file beginning
    while ((j = readln (fd, (char *)szData, 400)) > 1)
        {
 
//        j--;                              // deduct the flag byte
//pas de flag sinon 1 caractere en moins
        if (szData [j-1] == 0x30)           // do nothing if it's deleted
            continue;
 
        sum = Header [0] = k++ % 10;        // rotate from 0 to 9
 
        for (i=0; i<j-1; i++)
            sum += szData [i];
        szData [j-1] = sum & 0xFF;
        if (szData [j-1] == '\r')          // make sure the checksum isn't '\r'
            szData [j-1]++;
        szData [j] = sum >> 8;
        if (szData [j] == '\r')            // make sure the checksum isn't '\r'
            szData [j]++;
        szData [j+1] = '\r';
        szData [j+2] = 0;
 
        ltoa (k, szBuf, 10);
 
        DispString (11, 3, (BYTE*)szBuf, 0);        // show data transfered
 
 
ReSend:
        nwrite_com (nPort, (char *)Header, 1);
        while (com_eot(nPort)==0x00);
//manque un caractere
//        nwrite_com (nPort, (char *)szData, j+3);
        nwrite_com (nPort, (char *)szData, j+2);
 
        while (!com_eot (nPort));
ReDo:
        i = 0;
        while (i < 10)
            {
            if (read_com (nPort, (char *)&c))
                szBuf [i++] = c;
            if (c == '\r')
                break;
            if ((c = getchar()) == KEY_ESC)
                {
                lseek (fd, 0L, -1);    // 4.10+ move file pointer to the end
                close_com (nPort);
 
		close(fd);
 
                clr_scr ();
                return false;
                }
            }
        szBuf [i] = 0;
 
        if (!strcmp (szBuf, NAK))
            goto ReSend;
        else if (strcmp (szBuf, ACK))
            goto ReDo;
 
          OSTimeDly (1);
        }
 
    write_com (nPort, "OVER\r");
    while (!com_eot (nPort));
    write_com (nPort, "OVER\r");
    lseek (fd, 0L, -1);        // 4.10+ move file pointer to the end
 
    on_beeper (beep2);
    DispString (11, 3, OtherMsg [6], 0);        // Done
//    DispString (0, 5, Space15, 0);
//    DispString (0, 7, Space15, 0);
    close_com (nPort);
	close(fd);
    OSTimeDly (200);
    return TRUE;
    }
 
//-------------------------------------------------------------------------//
static BOOL ConnectingPage (void)
    {
     clr_scr();
     gotoxy(0,0);printf("TRANSMISSION");
     gotoxy(0,2);printf("==============");
     gotoxy(0,4);printf(" FICHIER EN  ");
     gotoxy(0,6);printf(" COURS       ");
     on_beeper (beep);
    return TRUE;
    }
 
//-------------------------------------------------------------------------//
void DispString (int x, int y, BYTE *str, int mode)
    {
    SetVideoMode (mode);
    gotoxy (x, y);
    printf ("%s", str);
    }
Merci