Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to remove this warning from MPLAB C18 Compiler??

Status
Not open for further replies.

xpress_embedo

Advanced Member level 4
Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,154
Helped
161
Reputation
396
Reaction score
189
Trophy points
1,353
Location
India
embeddedlaboratory.blogspot.in
Activity points
10,591
Hello!! i am using MPLAB X with MPLAB C18 v3.40 Compiler and using PIC18F27J53 Micro-Controller.

I want to remove these warnings, i am getting
Code:
Warning [2054] suspicious pointer conversion
and
Warning [2066] type qualifier mismatch in assignment

I had Written a simple LCD Program, to display data on LCD, and now wants to make a function, with which i can pass the first address of the array and it displays whole string.
For example:-
unsigned char text[] = "EDA BOARD";

and
Lcd_Text(text);
will display it on LCD, i had done it but getting a warning in this, pls help me to correct it.

This is my Code
Code:
#include <p18F27J53.h>
#include <delays.h>
#include <string.h>

/******************CONFIGURATION BITS****************/
#pragma config WDTEN = OFF          //WDT disabled (enabled by SWDTEN bit)
#pragma config PLLDIV = 5           //Divide by 5 (20 MHz oscillator input)
#pragma config STVREN = ON          //stack overflow/underflow reset enabled
#pragma config XINST = OFF          //Extended instruction set disabled
#pragma config CPUDIV = OSC1        //No CPU system clock divide
#pragma config CP0 = OFF            //Program memory is not code-protected
#pragma config OSC = HSPLL          //HS oscillator, PLL enabled, HSPLL used by USB
#pragma config FCMEN = OFF          //Fail-Safe Clock Monitor disabled
#pragma config IESO = OFF           //Two-Speed Start-up disabled
#pragma config WDTPS = 32768        //1:32768
#pragma config DSWDTOSC = INTOSCREF //DSWDT uses INTOSC/INTRC as clock
#pragma config RTCOSC = T1OSCREF    //RTCC uses T1OSC/T1CKI as clock
#pragma config DSBOREN = OFF        //Zero-Power BOR disabled in Deep Sleep
#pragma config DSWDTEN = OFF        //Disabled
#pragma config DSWDTPS = 8192       //1:8,192 (8.5 seconds)
#pragma config IOL1WAY = OFF        //IOLOCK bit can be set and cleared
#pragma config MSSP7B_EN = MSK7     //7 Bit address masking
#pragma config WPFP = PAGE_1        //Write Protect Program Flash Page 0
#pragma config WPEND = PAGE_0       //Start protection at page 0
#pragma config WPCFG = OFF          //Write/Erase last page protect Disabled
#pragma config WPDIS = OFF          //WPFP[5:0], WPEND, and WPCFG bits ignored
#pragma config CFGPLLEN = OFF
/****************************************************/

/****************PIN DETAILS****************/
#define LCD_RS	PORTCbits.RC0
#define LCD_RW	PORTCbits.RC1
#define LCD_EN	PORTCbits.RC2
#define LCD_DATA PORTB
#define CURSOR_OFF 0x0C
#define LCD_CLEAR 0x01
#define FIRST_ROW 0x80
#define SECOND_ROW 0xC0
/*******************************************/

/******************FUNCTION PROTOTYPE*******************/
void Delay_ms(unsigned int itime);
void Lcd_Init(void);
void Lcd_Cmd(unsigned char value);
void Lcd_Data(unsigned char value);
void Lcd_Text(unsigned char *msg);
/*******************************************************/

rom unsigned char text[] = "EDA BOARD";
void main()
{
    Lcd_Init();
    Lcd_Text(text);
    while(1);
}

/******************FUNCTION PROTOTYPE*******************/
void Delay_ms(unsigned int itime)
{
#ifndef __DELAY_IN_SEC
    #define __DELAY_IN_SEC
    unsigned int first;
    unsigned int second;
#endif
    for(first=0;first<itime;first++)
    {
        for(second=0;second<650;second++)
        {
            Delay1TCY();
        }
    }
}
void Lcd_Cmd(unsigned char value)
{
    LCD_DATA = value;
    LCD_RS = 0;
    LCD_RW = 0;
    LCD_EN = 1;
    Delay_ms(2);
    LCD_EN = 0;
    Delay_ms(1);
}
void Lcd_Data(unsigned char value)
{
    LCD_DATA = value;
    LCD_RS = 1;
    LCD_RW = 0;
    LCD_EN = 1;
    Delay_ms(2);
    LCD_EN = 0;
    Delay_ms(1);
}
void Lcd_Init(void)
{
    TRISB = 0x00;
    TRISCbits.TRISC0 = 0;
    TRISCbits.TRISC1 = 0;
    TRISCbits.TRISC2 = 0;
    Lcd_Cmd(0x38);			//Lcd_Initialize
    Delay_ms(10);
    Lcd_Cmd(CURSOR_OFF);
    Delay_ms(10);
    Lcd_Cmd(LCD_CLEAR);
    Delay_ms(10);
    Lcd_Cmd(FIRST_ROW);
    Delay_ms(5);
}
void Lcd_Text(unsigned char *msg)
{
#ifndef _LCD_STRING_LEN
#define _LCD_STRING_LEN
    unsigned char len;
    unsigned char pointer;
#endif
    len = strlen(msg);
    for(pointer=0;pointer<len;pointer++)
    {
        Lcd_Data(msg[pointer]);
    }
}
/*******************************************************/

I am getting both warning in this code.
Please suggest me something to solve this warning issue.
Although my code is working fine as expected, just want to remove this compiler warning
 

Change the code
Code:
 [syntax=c]
for(pointer=0;pointer<len;pointer++)
    {
        Lcd_Data(msg[pointer]);
    } [/syntax]

to the below code
Code:
 [syntax=c]
while(*msg) {
         Lcd_Data(*msg);
         msg++; 
} [/syntax]

Thanks sir it is working without any warning.
Can You pls explain me why it is so..

and the biggest problem, what i want to do is to store the string that to be displayed on lcd as constants in program memory.
like this
const rom unsigned char text[] = "EDA BOARD";
then how to do this
passing this to my function is not displaying any thing.
Pls help my main motive is to save ram space.
 

Your function prototype is something like

Code C - [expand]
1
Lcd_Data(char *msg);

So, it expects a pointer to a character variable. You are using

Code C - [expand]
1
Lcd_Data(msg[pointer]);

i.e., you are passing an array to the function.

If you want to use array then change your function prototype and definition to

Code C - [expand]
1
Lcd_Data(char msg[]);

and

Code C - [expand]
1
Lcd_Data(char msg[]) {...}

 
Last edited by a moderator:

Hi,
do it like this in your code.

Code:
void Puts_LCD( char *data, unsigned char count ) // data from SRAM
{
  	while ( count )
	{
		Lcd_Data( *data++ );
		count --;
	}	
}
and in your main function put data like this
Code:
Puts_LCD((char *)&text[0], (sizeof(text)) - 1 );
Hope this Helps
 

Doesn't this work
Code:
 rom unsigned char *text = "EDA BOARD";

No Sir this is not working :-(




Code C - [expand]
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
#include <p18F27J53.h>
#include <delays.h>
#include <string.h>
 
/******************CONFIGURATION BITS****************/
#pragma config WDTEN = OFF          //WDT disabled (enabled by SWDTEN bit)
#pragma config PLLDIV = 5           //Divide by 5 (20 MHz oscillator input)
#pragma config STVREN = ON          //stack overflow/underflow reset enabled
#pragma config XINST = OFF          //Extended instruction set disabled
#pragma config CPUDIV = OSC1        //No CPU system clock divide
#pragma config CP0 = OFF            //Program memory is not code-protected
#pragma config OSC = HSPLL          //HS oscillator, PLL enabled, HSPLL used by USB
#pragma config FCMEN = OFF          //Fail-Safe Clock Monitor disabled
#pragma config IESO = OFF           //Two-Speed Start-up disabled
#pragma config WDTPS = 32768        //1:32768
#pragma config DSWDTOSC = INTOSCREF //DSWDT uses INTOSC/INTRC as clock
#pragma config RTCOSC = T1OSCREF    //RTCC uses T1OSC/T1CKI as clock
#pragma config DSBOREN = OFF        //Zero-Power BOR disabled in Deep Sleep
#pragma config DSWDTEN = OFF        //Disabled
#pragma config DSWDTPS = 8192       //1:8,192 (8.5 seconds)
#pragma config IOL1WAY = OFF        //IOLOCK bit can be set and cleared
#pragma config MSSP7B_EN = MSK7     //7 Bit address masking
#pragma config WPFP = PAGE_1        //Write Protect Program Flash Page 0
#pragma config WPEND = PAGE_0       //Start protection at page 0
#pragma config WPCFG = OFF          //Write/Erase last page protect Disabled
#pragma config WPDIS = OFF          //WPFP[5:0], WPEND, and WPCFG bits ignored
#pragma config CFGPLLEN = OFF
/****************************************************/
 
/****************PIN DETAILS****************/
#define LCD_RS  PORTCbits.RC0
#define LCD_RW  PORTCbits.RC1
#define LCD_EN  PORTCbits.RC2
#define LCD_DATA PORTB
#define CURSOR_OFF 0x0C
#define LCD_CLEAR 0x01
#define FIRST_ROW 0x80
#define SECOND_ROW 0xC0
/*******************************************/
 
/******************FUNCTION PROTOTYPE*******************/
void Delay_ms(unsigned int itime);
void Lcd_Init(void);
void Lcd_Cmd(unsigned char value);
void Lcd_Data(unsigned char value);
void Lcd_Text(unsigned char msg[]);
/*******************************************************/
 
unsigned char text[] = "EDA BOARD";
 
void main()
{
    Lcd_Init();
    Lcd_Text(text);
    while(1);
}
 
/******************FUNCTION PROTOTYPE*******************/
void Delay_ms(unsigned int itime)
{
#ifndef __DELAY_IN_SEC
    #define __DELAY_IN_SEC
    unsigned int first;
    unsigned int second;
#endif
    for(first=0;first<itime;first++)
    {
        for(second=0;second<650;second++)
        {
            Delay1TCY();
        }
    }
}
void Lcd_Cmd(unsigned char value)
{
    LCD_DATA = value;
    LCD_RS = 0;
    LCD_RW = 0;
    LCD_EN = 1;
    Delay_ms(2);
    LCD_EN = 0;
    Delay_ms(1);
}
void Lcd_Data(unsigned char value)
{
    LCD_DATA = value;
    LCD_RS = 1;
    LCD_RW = 0;
    LCD_EN = 1;
    Delay_ms(2);
    LCD_EN = 0;
    Delay_ms(1);
}
void Lcd_Init(void)
{
    TRISB = 0x00;
    TRISCbits.TRISC0 = 0;
    TRISCbits.TRISC1 = 0;
    TRISCbits.TRISC2 = 0;
    Lcd_Cmd(0x38);          //Lcd_Initialize
    Delay_ms(10);
    Lcd_Cmd(CURSOR_OFF);
    Delay_ms(10);
    Lcd_Cmd(LCD_CLEAR);
    Delay_ms(10);
    Lcd_Cmd(FIRST_ROW);
    Delay_ms(5);
}
void Lcd_Text(unsigned char msg[])
{
    while(*msg)
    {
        Lcd_Data(*msg);
        msg++;
    }
}
/*******************************************************/



This code is working absolutely right without any warnings but after replacing line as

rom unsigned char *text = "EDA BOARD";

i am getting one warning and also nothing appears on my lcd, i want to display data on lcd from rom.
Please help
 

Hi,

Attached are one of the code that i am using from quite a while now. Just push in data like this
Code:
Puts_LCD("Welcome to EDA Board")
. Also the string ("Welcome to EDA Board") resides inside the ROM as it is a constant data. Dont worry if you are not using ROM key word in MPLAB C18. Also check your LCD configuration from attache d file.
 

Attachments

  • LCD display.c.txt
    2.5 KB · Views: 108
  • LCD display.h.txt
    1.4 KB · Views: 70

Try this

rom unsigned char text[] = "EDA BOARD";
unsigned char *textptr;

and in main() initialize
Code:
 textptr = &text;

No Sir, This doesn't works.
I found one code on internet and it is as follow:-


Code C - [expand]
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
#include <p18F27J53.h>
#include <delays.h>
#include <string.h>
 
/******************CONFIGURATION BITS****************/
#pragma config WDTEN = OFF          //WDT disabled (enabled by SWDTEN bit)
#pragma config PLLDIV = 5           //Divide by 5 (20 MHz oscillator input)
#pragma config STVREN = ON          //stack overflow/underflow reset enabled
#pragma config XINST = OFF          //Extended instruction set disabled
#pragma config CPUDIV = OSC1        //No CPU system clock divide
#pragma config CP0 = OFF            //Program memory is not code-protected
#pragma config OSC = HSPLL          //HS oscillator, PLL enabled, HSPLL used by USB
#pragma config FCMEN = OFF          //Fail-Safe Clock Monitor disabled
#pragma config IESO = OFF           //Two-Speed Start-up disabled
#pragma config WDTPS = 32768        //1:32768
#pragma config DSWDTOSC = INTOSCREF //DSWDT uses INTOSC/INTRC as clock
#pragma config RTCOSC = T1OSCREF    //RTCC uses T1OSC/T1CKI as clock
#pragma config DSBOREN = OFF        //Zero-Power BOR disabled in Deep Sleep
#pragma config DSWDTEN = OFF        //Disabled
#pragma config DSWDTPS = 8192       //1:8,192 (8.5 seconds)
#pragma config IOL1WAY = OFF        //IOLOCK bit can be set and cleared
#pragma config MSSP7B_EN = MSK7     //7 Bit address masking
#pragma config WPFP = PAGE_1        //Write Protect Program Flash Page 0
#pragma config WPEND = PAGE_0       //Start protection at page 0
#pragma config WPCFG = OFF          //Write/Erase last page protect Disabled
#pragma config WPDIS = OFF          //WPFP[5:0], WPEND, and WPCFG bits ignored
#pragma config CFGPLLEN = OFF
/****************************************************/
 
/****************PIN DETAILS****************/
#define LCD_RS  PORTCbits.RC0
#define LCD_RW  PORTCbits.RC1
#define LCD_EN  PORTCbits.RC2
#define LCD_DATA PORTB
#define CURSOR_OFF 0x0C
#define LCD_CLEAR 0x01
#define FIRST_ROW 0x80
#define SECOND_ROW 0xC0
/*******************************************/
 
/******************FUNCTION PROTOTYPE*******************/
void Delay_ms(unsigned int itime);
void Lcd_Init(void);
void Lcd_Cmd(unsigned char value);
void Lcd_Data(unsigned char value);
void Lcd_Text(unsigned char msg[]);
unsigned char * ConstToRAM(unsigned char * dest, const rom unsigned char * src);
/*******************************************************/
 
const rom unsigned char text[] = "EDA BOARD";
const rom unsigned char name[] = "Arun Sharma";
unsigned char msg[16];
void main()
{
    Lcd_Init();
    ConstToRAM(msg,text);
    Lcd_Text(msg);
    ConstToRAM(msg,name);
    Lcd_Cmd(SECOND_ROW);
    Lcd_Text(msg);
    while(1);
}
 
/******************FUNCTION PROTOTYPE*******************/
void Delay_ms(unsigned int itime)
{
#ifndef __DELAY_IN_SEC
    #define __DELAY_IN_SEC
    unsigned int first;
    unsigned int second;
#endif
    for(first=0;first<itime;first++)
    {
        for(second=0;second<650;second++)
        {
            Delay1TCY();
        }
    }
}
void Lcd_Cmd(unsigned char value)
{
    LCD_DATA = value;
    LCD_RS = 0;
    LCD_RW = 0;
    LCD_EN = 1;
    Delay_ms(2);
    LCD_EN = 0;
    Delay_ms(1);
}
void Lcd_Data(unsigned char value)
{
    LCD_DATA = value;
    LCD_RS = 1;
    LCD_RW = 0;
    LCD_EN = 1;
    Delay_ms(2);
    LCD_EN = 0;
    Delay_ms(1);
}
void Lcd_Init(void)
{
    TRISB = 0x00;
    TRISCbits.TRISC0 = 0;
    TRISCbits.TRISC1 = 0;
    TRISCbits.TRISC2 = 0;
    Lcd_Cmd(0x38);          //Lcd_Initialize
    Delay_ms(10);
    Lcd_Cmd(CURSOR_OFF);
    Delay_ms(10);
    Lcd_Cmd(LCD_CLEAR);
    Delay_ms(10);
    Lcd_Cmd(FIRST_ROW);
    Delay_ms(5);
}
void Lcd_Text(unsigned char msg[])
{
    while(*msg)
    {
        Lcd_Data(*msg);
        msg++;
    }
}
unsigned char * ConstToRAM(unsigned char * dest, const rom unsigned char * src)
{
    /*for(;*dest++ = *src++;)
    ;*/
    while(*src)
    {
        *dest++ = *src++;
    }
    return dest;
}
/*******************************************************/



I understand this code, but i want to ask some thing related to for loop.

Code:
unsigned char * ConstToRAM(unsigned char * dest, const rom unsigned char * src)
{
    /*for(;*dest++ = *src++;)
    ;
    */
    while(*src)
    {
        *dest++ = *src++;
    }
    return dest;
}

The code i found, used the above for loop, i changed it and use my while loop.
I want to know, how they had used that for loop.


And yes i am not getting any warning in my program now and even my ram space is saved also

- - - Updated - - -

Try this

rom unsigned char text[] = "EDA BOARD";
unsigned char *textptr;

and in main() initialize
Code:
 textptr = &text;

No Sir, This doesn't works.
I found one code on internet and it is as follow:-


Code C - [expand]
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
#include <p18F27J53.h>
#include <delays.h>
#include <string.h>
 
/******************CONFIGURATION BITS****************/
#pragma config WDTEN = OFF          //WDT disabled (enabled by SWDTEN bit)
#pragma config PLLDIV = 5           //Divide by 5 (20 MHz oscillator input)
#pragma config STVREN = ON          //stack overflow/underflow reset enabled
#pragma config XINST = OFF          //Extended instruction set disabled
#pragma config CPUDIV = OSC1        //No CPU system clock divide
#pragma config CP0 = OFF            //Program memory is not code-protected
#pragma config OSC = HSPLL          //HS oscillator, PLL enabled, HSPLL used by USB
#pragma config FCMEN = OFF          //Fail-Safe Clock Monitor disabled
#pragma config IESO = OFF           //Two-Speed Start-up disabled
#pragma config WDTPS = 32768        //1:32768
#pragma config DSWDTOSC = INTOSCREF //DSWDT uses INTOSC/INTRC as clock
#pragma config RTCOSC = T1OSCREF    //RTCC uses T1OSC/T1CKI as clock
#pragma config DSBOREN = OFF        //Zero-Power BOR disabled in Deep Sleep
#pragma config DSWDTEN = OFF        //Disabled
#pragma config DSWDTPS = 8192       //1:8,192 (8.5 seconds)
#pragma config IOL1WAY = OFF        //IOLOCK bit can be set and cleared
#pragma config MSSP7B_EN = MSK7     //7 Bit address masking
#pragma config WPFP = PAGE_1        //Write Protect Program Flash Page 0
#pragma config WPEND = PAGE_0       //Start protection at page 0
#pragma config WPCFG = OFF          //Write/Erase last page protect Disabled
#pragma config WPDIS = OFF          //WPFP[5:0], WPEND, and WPCFG bits ignored
#pragma config CFGPLLEN = OFF
/****************************************************/
 
/****************PIN DETAILS****************/
#define LCD_RS  PORTCbits.RC0
#define LCD_RW  PORTCbits.RC1
#define LCD_EN  PORTCbits.RC2
#define LCD_DATA PORTB
#define CURSOR_OFF 0x0C
#define LCD_CLEAR 0x01
#define FIRST_ROW 0x80
#define SECOND_ROW 0xC0
/*******************************************/
 
/******************FUNCTION PROTOTYPE*******************/
void Delay_ms(unsigned int itime);
void Lcd_Init(void);
void Lcd_Cmd(unsigned char value);
void Lcd_Data(unsigned char value);
void Lcd_Text(unsigned char msg[]);
unsigned char * ConstToRAM(unsigned char * dest, const rom unsigned char * src);
/*******************************************************/
 
const rom unsigned char text[] = "EDA BOARD";
const rom unsigned char name[] = "Arun Sharma";
unsigned char msg[16];
void main()
{
    Lcd_Init();
    ConstToRAM(msg,text);
    Lcd_Text(msg);
    ConstToRAM(msg,name);
    Lcd_Cmd(SECOND_ROW);
    Lcd_Text(msg);
    while(1);
}
 
/******************FUNCTION PROTOTYPE*******************/
void Delay_ms(unsigned int itime)
{
#ifndef __DELAY_IN_SEC
    #define __DELAY_IN_SEC
    unsigned int first;
    unsigned int second;
#endif
    for(first=0;first<itime;first++)
    {
        for(second=0;second<650;second++)
        {
            Delay1TCY();
        }
    }
}
void Lcd_Cmd(unsigned char value)
{
    LCD_DATA = value;
    LCD_RS = 0;
    LCD_RW = 0;
    LCD_EN = 1;
    Delay_ms(2);
    LCD_EN = 0;
    Delay_ms(1);
}
void Lcd_Data(unsigned char value)
{
    LCD_DATA = value;
    LCD_RS = 1;
    LCD_RW = 0;
    LCD_EN = 1;
    Delay_ms(2);
    LCD_EN = 0;
    Delay_ms(1);
}
void Lcd_Init(void)
{
    TRISB = 0x00;
    TRISCbits.TRISC0 = 0;
    TRISCbits.TRISC1 = 0;
    TRISCbits.TRISC2 = 0;
    Lcd_Cmd(0x38);          //Lcd_Initialize
    Delay_ms(10);
    Lcd_Cmd(CURSOR_OFF);
    Delay_ms(10);
    Lcd_Cmd(LCD_CLEAR);
    Delay_ms(10);
    Lcd_Cmd(FIRST_ROW);
    Delay_ms(5);
}
void Lcd_Text(unsigned char msg[])
{
    while(*msg)
    {
        Lcd_Data(*msg);
        msg++;
    }
}
unsigned char * ConstToRAM(unsigned char * dest, const rom unsigned char * src)
{
    /*for(;*dest++ = *src++;)
    ;*/
    while(*src)
    {
        *dest++ = *src++;
    }
    return dest;
}
/*******************************************************/



I understand this code, but i want to ask some thing related to for loop.

Code:
unsigned char * ConstToRAM(unsigned char * dest, const rom unsigned char * src)
{
    /*for(;*dest++ = *src++;)
    ;
    */
    while(*src)
    {
        *dest++ = *src++;
    }
    return dest;
}

The code i found, used the above for loop, i changed it and use my while loop.
I want to know, how they had used that for loop.


And yes i am not getting any warning in my program now and even my ram space is saved also
 

Code:
 [syntax=c] unsigned char * ConstToRAM(unsigned char * dest, const rom unsigned char * src)
{
    for(;*dest++ = *src++;)   
    
    
} [/syntax]

The for loop loops till *dest++ = src++

The loop starts from *dest then on every loop *dest and *src are incremented

*dest and *src points to some string.

Ever loop *src is incremented and assigned to *dest++. If the value of *dest++ is true that is not null ['\0'] the code inside the for loop is executed.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top