A code:
Copy Code code as follows:
#include <stdio.h>
#include <stdlib.h>
#define UCHAR unsigned char
#define UINT unsigned int
void display (Uchar *p);
Char h[4] = {' A ', ' B ', ' C ', ' n '};
Char e[4] = {' E ', ' F ', ' L ', ' n '};
Char l[4] = {' M ', ' N ', ' O ', ' I '};
Char o[4] = {' X ', ' Y ', ' Z ', ' n '};
int main (void)
{
int i;
char c;
UINT SET[5];
Set[0] = h;
SET[1] = e;
SET[2] = l;
SET[3] = l;
SET[4] = o;
while (1) {
for (i = 0; i < 5; ++i) {
Display (Set[i]);
printf ("\ n");
Sleep (1);
}
}
}
void display (Uchar *p)
{
while (*p!= ' ") {
printf ("%c", *p);
printf ("%c", * (p+1));
++p;
}
}
alerts are as follows:
TEST.C:21: Warning: Assigning pointers to integers with no type conversion
TEST.C:22: Warning: Assigning pointers to integers with no type conversion
TEST.C:23: Warning: Assigning pointers to integers with no type conversion
TEST.C:24: Warning: Assigning pointers to integers with no type conversion
TEST.C:25: Warning: Assigning pointers to integers with no type conversion
TEST.C:29: Warning: Assigning an integer to a pointer when parameter 1 (' Display ') is passed, without type conversion
21-25 of them are
Set[0] = h;
SET[1] = e;
SET[2] = l;
SET[3] = l;
SET[4] = o;
29 is
Display (Set[i])
It's just an alarm, and it's good to run under Linux. But since the warning, it is worth discussing.
To be Continued ~
In the interest of ...
If any of you know. Can you reply and tell me?
------------------------------------------------------------
On this question, I asked xiaoding in the bedroom. After his amendment, the procedure has not been reported as a warning.
Copy Code code as follows:
#include <stdio.h>
#include <stdlib.h>
#define UCHAR unsigned char
#define UINT unsigned int
void display (Uchar *p);
Char h[4] = {' A ', ' B ', ' C ', ' n '};
Char e[4] = {' E ', ' F ', ' L ', ' n '};
Char l[4] = {' M ', ' N ', ' O ', ' I '};
Char o[4] = {' X ', ' Y ', ' Z ', ' n '};
int main (void)
{
int i;
char c;
int set[5];
SET[0] = (int) h;
SET[1] = (int) e;
SET[2] = (int) l;
SET[3] = (int) l;
SET[4] = (int) o;
while (1) {
for (i = 0; i < 5; ++i) {
Display ((UCHAR *) set[i]);
printf ("\ n");
Sleep (1);
}
}
}
void display (Uchar *p)
{
while (*p!= ' ") {
printf ("%c", *p);
printf ("%c", * (p+1));
++p;
}
}
Cast to int in the first address assignment of the font array. In function invocation. Because the input is required in the child function as the pointer, so in the previous call, can not simply write set[i]. Instead of passing the pointer over. The coercion type conversion (UCHAR *) is to match (Uchar *p).
-------------------------------------------
the 2 points that should be noted are:
1. The pointer can only be transmitted to the address, can not be transmitted. Otherwise, you will be forced to type conversions.
2. When doing type conversion and assignment, you should pay attention to the type of assignment matching.