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 typecast in mplab (mplab c compiler)

Status
Not open for further replies.

dhakeparag81

Full Member level 2
Full Member level 2
Joined
Jun 6, 2012
Messages
142
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
INDIA
Visit site
Activity points
2,469
hi there,

I m trying o typecast char array to int.

i define one string str1 and title_ptr as a int pointer, i am tryint to assign str1[0] address to int but it shows error "type mismatch in assignment"

please tell me how to assign address of str1[0] to title_ptr;
Code:
unsigned char str1[50];
unsigned int *title_ptr;

void main(void)
{
.....
...
title_ptr = (int) &str1[0];

}
please help me as early as possible because i m just close to my project and i like to share all project related data here.
 

The question isn't specific to MPLAB, just a matter of basic C syntax.

If you want to type cast to an int pointer, you need to write (int*) rather than (int).
 

@FvM,
I tried last night (int*) but the problem remain same.
i recently know that pointer which i used is tried to access some restricted memory because of pointer memory holding limit,when i increment that pointer at some instance it overflow bcoz of limit and then tried to access restricted memory.

- - - Updated - - -

I attached one image of mplab ide when i m debug through pic kit3.
if u see the image and code u will wonder, in that pointer is pointing to some other unexpected location.
I didn't get it.

if u know reason please let me know.
Code:
/* as we use huge ammount of array its address is definatly lager than 255 and we use pointer of char
so when address goes high stack is overflow and data is loss in pointer
*/


#include<p18f4520.h>
#include<delays.h>

#define CS1 LATCbits.LATC2
#define CS2 LATCbits.LATC1
#define CS3 LATCbits.LATC0
#define CS4 LATEbits.LATE2
#define CS5 LATEbits.LATE1
#define CS6 LATEbits.LATE0

#define CLK1 LATBbits.LATB5
#define CLK2 LATBbits.LATB4
#define CLK3 LATBbits.LATB3
#define CLK4 LATBbits.LATB2
#define CLK5 LATBbits.LATB1
#define CLK6 LATBbits.LATB0

#define SDATA1 LATCbits.LATC6
#define SDATA2 LATCbits.LATC7
#define SDATA3 LATDbits.LATD4
#define SDATA4 LATDbits.LATD5
#define SDATA5 LATDbits.LATD6
#define SDATA6 LATDbits.LATD7

#define DATA1 LATCbits.LATC3
#define DATA2 LATDbits.LATD0
#define DATA3 LATDbits.LATD1
#define DATA4 LATCbits.LATC5
#define DATA5 LATCbits.LATC4
#define DATA6 LATDbits.LATD3

#pragma idata name0

unsigned char str1[50]="J.T. MAHAJAN, C.O.E., FAIZPUR, DEPT. OF E&TC.  ";
unsigned char str2[70]="A.M. PATIL PROF. & H.O.D.  P.M. MAHAJAN ASSO. PROF.  ";
unsigned char str3[70]="S.V. PATIL  ASSO. PROF.  K.S. BHAGAT  ASS. PROF. ";

#pragma idata name7
unsigned char str4[80]="N.S. PATIL  ASS. PROF.  O.K. FIRKE ASS. PROF.  R.C. BAKSHE ASS. PROF  ";
unsigned char str5[80]="G.D. BONDE ASS. PROF.  A.B. NEHETE ASS. PROF.  G.L. ATTERDE ASS. PROF. ";
unsigned char str6[85]="R.D. CHAUDHARI ASS. PROF.  S.R. PACHPANDE ASS. PROF.  Y.K. KIRANGE ASS. PROF.  ";

#pragma idata name1

unsigned char alphabets[185]={0x04, 0x0A, 0x11, 0x11, 0x1F, 0x11, 0x11,		//A
							  0x0F, 0x11, 0x11, 0x0F, 0x11, 0x11, 0x0F,		//B
							  0x0E, 0x11, 0x01, 0x01, 0x01, 0x11, 0x0E,		//C
							  0x0F, 0x12, 0x12, 0x12, 0x12, 0x12, 0x0F,		//D
							  0x1F, 0x01, 0x01, 0x0F, 0x01, 0x01, 0x1F,		//E
							  0x1F, 0x01, 0x01, 0x07, 0x01, 0x01, 0x01,		//F
							  0x0E, 0x11, 0x01, 0x1D, 0x11, 0x11, 0x0E,		//G
							  0x11, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11,		//H
							  0x0E, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E,		//I
							  0x1C, 0x08, 0x08, 0x08, 0x08, 0x09, 0x06,		//J
							  0x11, 0x09, 0x05, 0x03, 0x05, 0x09, 0x11,		//K
							  0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1F,		//L
							  0x11, 0x1B, 0x15, 0x15, 0x11, 0x11, 0x11,		//M
							  0x11, 0x13, 0x15, 0x19, 0x11, 0x11, 0x11,		//N
							  0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E,		//O
							  0x0F, 0x11, 0x11, 0x0F, 0x01, 0x01, 0x01,		//P
							  0x0E, 0x11, 0x11, 0x11, 0x15, 0x09, 0x16,		//Q
							  0x0F, 0x11, 0x11, 0x0F, 0x05, 0x09, 0x11,		//R
							  0x0E, 0x11, 0x01, 0x0E, 0x10, 0x11, 0x0E,		//S
							  0x1F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,		//T
							  0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E,		//U
							  0x11, 0x11, 0x11, 0x0A, 0x0A, 0x04, 0x04,		//V
							  0x11, 0x11, 0x11, 0x15, 0x15, 0x1B, 0x11,		//W
							  0x11, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x11,		//X
							  0x11, 0x11, 0x0A, 0x04, 0x04, 0x04, 0x04,		//Y
							  0x1F, 0x10, 0x08, 0x04, 0x02, 0x01, 0x1F};	//Z

#pragma udata namei1
unsigned char sp_array[30]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,		//.
							  0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x02, 	//,
							  0x02, 0x05, 0x05, 0x02, 0x15, 0x09, 0x16,		//&
							  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};	//

#pragma idata name2
							  
unsigned char no_shift=0;
unsigned char k=0, j=0, i=0, jk=0, count=0,count2=0,count3=0,count4=0,count5=0,count6=0, shifting1=0,shifting2=0,shifting3=0,shifting4=0,shifting5=0,shifting6=0, temp1=0;
unsigned char shift_data=0;

#pragma udata name5
unsigned int *title_ptr=0, *first_ptr=0, *second_ptr=0, *third_ptr=0, *fourth_ptr=0, *fifth_ptr=0, *sixth_ptr=0;
unsigned char *temp_ptr=0,*tmp=0;

#pragma udata name3
unsigned char temp_array[16]={0}; 

#pragma idata name4

void nop(void);
unsigned int* title_row(unsigned int *ptr);
void char_data_conv(unsigned char *chr_ptr);
void data_conversion(unsigned char data);
void nop(void);
unsigned int* second_row(unsigned int *ptr2);
unsigned int* third_row(unsigned int *ptr2);
unsigned int* fourth_row(unsigned int *ptr2);
unsigned int* fifth_row(unsigned int *ptr2);
unsigned int* sixth_row(unsigned int *ptr2);

#pragma code High_Vector_Section=0x08
void high_isr (void);

void High_Vector_Section (void)
{
	_asm goto high_isr _endasm
}

/***********************************************************************************************************************************************************************************************************/

#pragma code
#pragma interrupt high_isr

void high_isr()
{
	
	
	if(INTCONbits.TMR0IF == 1)							// Timer0 causes interrupt.....?
    {
	   										// Yes Then Execute Timer0 ISR.
	   INTCONbits.TMR0IF = 0;
	}

	
}


void main (void)
{

	//OSCTUNE		= 0x80;									//INTSRC = 1.		
	//OSCCON		= 0x76;									//IRCF2:IRCF0 = 1 i.e 8 MHz, I0FS = 1 Freq Is Stable, SCS1:SCS0 = 10 i.e Internal OSC Block.

	RCON		= 0xDF;									//IPEN = 1....
	INTCON		= 0xE0;									// GIE = 1, PEIE = 1, TMR0IE = 1.
	INTCON2		= 0x00;
	INTCON3		= 0x00;	
	
	T0CON		= 0x88;									//TMR0ON = 1, PSA = 1.
	TMR0H		= 0xB1;									//Timer0 Registers.
	TMR0L		= 0xDF;
	
	ADCON1		= 0x0F;									//A/D OFF, Configure As Digital I/O Pin.
	CMCON		= 0x07;							
		
	INTCONbits.INT0IF=0;
	INTCONbits.RBIF=0;
	
	

	TRISCbits.TRISC2=0;
	TRISCbits.TRISC5=0;
	TRISCbits.TRISC4=0;
	TRISCbits.TRISC1=0;
	TRISCbits.TRISC0=0;
	TRISCbits.TRISC3=0;
	TRISEbits.TRISE2=0;
	TRISEbits.TRISE1=0;
	TRISEbits.TRISE0=0;
	
	TRISBbits.TRISB5=0;
	TRISBbits.TRISB4=0;
	TRISBbits.TRISB3=0;
	TRISBbits.TRISB2=0;
	TRISBbits.TRISB1=0;
	TRISBbits.TRISB0=0;
	
	
	
	TRISCbits.TRISC6=0;
	TRISCbits.TRISC7=0;
	TRISDbits.TRISD4=0;
	TRISDbits.TRISD5=0;
	TRISDbits.TRISD6=0;
	TRISDbits.TRISD7=0;
	TRISDbits.TRISD0=0;
	TRISDbits.TRISD1=0; 
	TRISDbits.TRISD3=0; 
	TRISC=0;
	TRISD=0;
	TRISE=0;
	
	CS1=0;
	CS2=0;
	CS3=0;
	CS4=0;
	CS5=0;
	CS6=0;

title_ptr = ((void *)(&str1[0]));
second_ptr = ((void *)(&str2[0]));
third_ptr = (void *)&str3[0];
fourth_ptr = (void*)&str4[0];
fifth_ptr = (void*)&str5[0];
sixth_ptr = (void*)&str6[0];
	
	for(i=0;i<72;i++)
	{	
			
		DATA1=0;
		DATA2=0;
		DATA3=0;
		DATA4=0;
		DATA5=0;
		CS1=1;
		SDATA1=1;
		CLK1=0;
		CLK1=1;
		CLK1=0;
		
		CS1=0;
		
	}
	
	
	SDATA1=0;
	while(1)
	{

			
		title_ptr = title_row(title_ptr);	
	//	second_ptr = second_row(second_ptr);
		//third_ptr = second_row(second_ptr);
		//fourth_ptr = second_row(second_ptr);
		//fifth_ptr = second_row(second_ptr);
		//sixth_ptr = second_row(second_ptr);

	}	
}	

unsigned int* title_row(unsigned int *ptr)
{	 
	title_ptr = ptr;
	SDATA1=0;
	k=0;
	
	count++;
	
	if(count>100)
	{
		count=0;
		shifting1 += 1;
	}	
	
	 for(no_shift = 0; no_shift<10; no_shift++)
	 {
		 jk=0;
		 char_data_conv((void *)ptr);
		 tmp = (void*)ptr;	
		 tmp++;	 	 
		 ptr=(void*)tmp;
		
		 if((void *)ptr > ((void *)&str1[45]))
		 {
			 ptr = (void*)&str1[0];
		 } 
		 char_data_conv((void *)ptr);

		 
		for(k=0;k<7;k++)
		{
			 shift_data = temp_array[k] >> shifting1;
			 
			 temp1 = temp_array[k + 7];
			 temp1 = temp1 << (5 - shifting1);
			 shift_data = shift_data | temp1;
			 
			 data_conversion(shift_data);
			CS1=1;
			CS1=0;
			
			 CLK1=0;
			 CLK1=1;
			 CLK1=0;
			 SDATA1=1;
		} 
	
		if((void*)ptr > (void*)(&str1[45]))
		{
			 ptr = (void*)&str1[0];
		}
	 } 
	 
	 if(shifting1 >= 4)
	 {
		 tmp = (void*)title_ptr;
		 tmp++;
		 title_ptr = (void*)tmp;
		 shifting1 = 0;
		 
	 } 
	 
	if((void*)title_ptr > ((void*)&str1[45]))
	{
	 	 title_ptr = (void*)&str1[0];
	} 
	 
	 return title_ptr;
}	


unsigned int* second_row(unsigned int *ptr2)
{	 
	second_ptr = ptr2;
	SDATA2=0;
	k=0;
	
	count2++;
	
	if(count2>50)
	{
		count2=0;
		shifting2 += 1;
	}	
	
	 for(no_shift = 0; no_shift<10; no_shift++)
	 {
		 jk=0;
		 char_data_conv((void*)ptr2);	 	 
		 ptr2+=1;
		 
		 if((void*)ptr2 > (void*)(&str2[52]))
		 {
			 ptr2 = (void*)&str2[0];
		 } 
		 char_data_conv((void*)ptr2);

		 
		for(k=0;k<7;k++)
		{
			 shift_data = temp_array[k] >> shifting2;
			 
			 temp1 = temp_array[k + 7];
			 temp1 = temp1 << (5 - shifting2);
			 shift_data = shift_data | temp1;
			 
			 data_conversion(shift_data);
			CS2=1;
			CS2=0;
			
			 CLK2=0;
			 CLK2=1;
			 CLK2=0;
			 SDATA2=1;
			 		 
		} 
	
		if((void*)ptr2 > (void*)(&str2[52]))
		{
			 ptr2 = (void*)&str2[0];
		}
	 } 
	 
	 if(shifting2 >= 4)
	 {
		 second_ptr++;
		 shifting2 = 0;
	 } 
	 
	if((void*)second_ptr > (void*)(&str2[52]))
	{
	 	 second_ptr = (void*)&str2[0];
	} 
	 
	 return second_ptr;
}	


unsigned int* third_row(unsigned int *ptr3)
{	 
	third_ptr = ptr3;
	SDATA3=0;
	k=0;
	
	count3++;
	
	if(count3>100)
	{
		count3=0;
		shifting3 += 1;
	}	
	
	 for(no_shift = 0; no_shift<10; no_shift++)
	 {
		 jk=0;
		 char_data_conv((void*)ptr3);		 	 
		 ptr3++;
		 
		 if((void*)ptr3 > (void*)(&str3[45]))
		 {
			 ptr3 = (void*)&str3[0];
		 } 
		 char_data_conv((void*)ptr3);

		 
		for(k=0;k<7;k++)
		{
			 shift_data = temp_array[k] >> shifting3;
			 
			 temp1 = temp_array[k + 7];
			 temp1 = temp1 << (5 - shifting3);
			 shift_data = shift_data | temp1;
			 
			 data_conversion(shift_data);
			CS3=1;
			CS3=0;
			
			 CLK3=0;
			 CLK3=1;
			 CLK3=0;
			 SDATA3=1;
					 
		} 
	
		if((void*)ptr3 > (void*)(&str3[45]))
		{
			 ptr3 = (void*)&str3[0];
		}
	 } 
	 
	 if(shifting3 >= 4)
	 {
		 third_ptr++;
		 shifting3 = 0;
	 } 
	 
	if((void*)third_ptr > (void*)(&str3[45]))
	{
	 	 third_ptr = (void*)&str3[0];
	} 
	 
	 return third_ptr;
}	


unsigned int* foruth_row(unsigned int *ptr4)
{	 
	fourth_ptr = ptr4;
	SDATA4=0;
	k=0;
	
	count4++;
	
	if(count4>100)
	{
		count4=0;
		shifting4 += 1;
	}	
	
	 for(no_shift = 0; no_shift<10; no_shift++)
	 {
		 jk=0;
		 char_data_conv((void*)ptr4);		 	 
		 ptr4++;
		 
		 if((void*)ptr4 > (void*)(&str4[45]))
		 {
			 ptr4 = (void*)&str4[0];
		 } 
		 char_data_conv((void*)ptr4);

		 
		for(k=0;k<7;k++)
		{
			 shift_data = temp_array[k] >> shifting4;
			 
			 temp1 = temp_array[k + 7];
			 temp1 = temp1 << (5 - shifting4);
			 shift_data = shift_data | temp1;
			 
			 data_conversion(shift_data);
			CS4=1;
			
			CS4=0;
			
			 CLK4=0;
			 CLK4=1;
			 CLK4=0;
			 SDATA4=1;
			 
		} 
	
		if((void*)ptr4 > (void*)(&str4[45]))
		{
			 ptr4 = (void*)&str4[0];
		}
	 } 
	 
	 if(shifting4 >= 4)
	 {
		 fourth_ptr++;
		 shifting4 = 0;
	 } 
	 
	if((void*)fourth_ptr > (void*)(&str4[45]))
	{
	 	 fourth_ptr = (void*)&str4[0];
	} 
	 
	 return fourth_ptr;
}	


unsigned int* fifth_row(unsigned int *ptr5)
{	 
	fifth_ptr = ptr5;
	SDATA5=0;
	k=0;
	
	count5++;
	
	if(count5>100)
	{
		count5=0;
		shifting5 += 1;
	}	
	
	 for(no_shift = 0; no_shift<10; no_shift++)
	 {
		 jk=0;
		 char_data_conv((void*)ptr5);		 	 
		 ptr5++;
		 
		 if((void*)ptr5 > (void*)(&str5[45]))
		 {
			 ptr5 = (void*)&str5[0];
		 } 
		 char_data_conv((void*)ptr5);

		 
		for(k=0;k<7;k++)
		{
			 shift_data = temp_array[k] >> shifting5;
			 
			 temp1 = temp_array[k + 7];
			 temp1 = temp1 << (5 - shifting5);
			 shift_data = shift_data | temp1;
			 
			 data_conversion(shift_data);
			CS5=1;
			CS5=0;
			
			 CLK5=0;
			 CLK5=1;
			 CLK5=0;
			 SDATA5=1;
			 
			 
		} 
	
		if((void*)ptr5 > (void*)(&str5[45]))
		{
			 ptr5 = (void*)&str5[0];
		}
	 } 
	 
	 if(shifting5 >= 4)
	 {
		 fifth_ptr++;
		 shifting5 = 0;
	 } 
	 
	if((void*)fifth_ptr > (void*)(&str5[45]))
	{
	 	 fifth_ptr = (void*)&str5[0];
	} 
	 
	 return fifth_ptr;
}	


unsigned int* sixth_row(unsigned int *ptr6)
{	 
	sixth_ptr = ptr6;
	SDATA6=0;
	k=0;
	
	count6++;
	
	if(count6>100)
	{
		count6=0;
		shifting6 += 1;
	}	
	
	 for(no_shift = 0; no_shift<10; no_shift++)
	 {
		 jk=0;
		 char_data_conv((void*)ptr6);		 	 
		 ptr6++;
		 
		 if((void*)ptr6 > (void*)(&str6[45]))
		 {
			 ptr6 = (void*)&str6[0];
		 } 
		 char_data_conv((void*)ptr6);

		 
		for(k=0;k<7;k++)
		{
			 shift_data = temp_array[k] >> shifting6;
			 
			 temp1 = temp_array[k + 7];
			 temp1 = temp1 << (5 - shifting6);
			 shift_data = shift_data | temp1;
			 
			 data_conversion(shift_data);
			CS6=1;
			CS6=0;
			
			 CLK6=0;
			 CLK6=1;
			 CLK6=0;
			 SDATA6=1;
			 
		} 
	
		if((void*)ptr6 > (void*)(&str6[45]))
		{
			 ptr6 = (void*)&str6[0];
		}
	 } 
	 
	 if(shifting6 >= 4)
	 {
		 sixth_ptr++;
		 shifting6 = 0;
	 } 
	 
	if((void*)sixth_ptr > (void*)(&str6[45]))
	{
	 	 sixth_ptr = (void*)&str6[0];
	} 
	 
	 return sixth_ptr;
}	


void char_data_conv(unsigned char *chr_ptr)
{
	switch(*(chr_ptr))
	{
		case 'A':
				temp_ptr = &(alphabets[0]);
				break;
		case 'B':
				temp_ptr = &alphabets[7];
				break;
		case 'C':
				temp_ptr = &alphabets[14];
				break;
		case 'D':
				temp_ptr = &alphabets[21];
				break;
		case 'E':
				temp_ptr = &alphabets[28];
				break;
		case 'F':
				temp_ptr = &alphabets[35];
				break;
		case 'G':
				temp_ptr = &alphabets[42];
				break;
		case 'H':
				temp_ptr = &alphabets[49];
				break;
		case 'I':
				temp_ptr = &alphabets[56];
				break;
		case 'J':
				temp_ptr = &alphabets[63];
				break;
		case 'K':
				temp_ptr = &alphabets[70];
				break;
		case 'L':
				temp_ptr = &alphabets[77];
				break;
		case 'M':
				temp_ptr = &alphabets[84];
				break;
		case 'N':
				temp_ptr = &alphabets[91];
				break;
		case 'O':
				temp_ptr = &alphabets[98];
				break;
		case 'P':
				temp_ptr = &alphabets[105];
				break;
		case 'Q':
				temp_ptr = &alphabets[112];
				break;
		case 'R':
				temp_ptr = &alphabets[119];
				break;
		case 'S':
				temp_ptr = &alphabets[126];
				break;
		case 'T':
				temp_ptr = &alphabets[133];
				break;
		case 'U':
				temp_ptr = &alphabets[140];
				break;
		case 'V':
				temp_ptr = &alphabets[147];
				break;
		case 'W':
				temp_ptr = &alphabets[154];
				break;
		case 'X':
					temp_ptr = &alphabets[161];
				break;
		case 'Y':
				temp_ptr = &alphabets[168];
				break;
		case 'Z':
				temp_ptr = &alphabets[175];
				break;
		case '.':
				temp_ptr = &sp_array[0];
				break;
		case ',':
				temp_ptr = &sp_array[7];
				break;
		case '&':
				temp_ptr = &sp_array[14];
				break;
		
		case ' ':
				temp_ptr = &sp_array[21];
				break;
				
	}
	
	for(j=0; j<7; j++)
	{
		temp_array[jk] = *temp_ptr;
		temp_ptr++; 
		jk++;
	}	
}	


void nop(void)
{
	unsigned int i=0;
	for(i=5;i>0;i--);
}	

void data_conversion(unsigned char data)
{
	if(data & 0x01)
	{
		LATCbits.LATC3=1;
	}	
	else
	{
		LATCbits.LATC3=0;
	}	
	
	if(data & 0x02)
	{
		LATDbits.LATD0=1;
	}	
	else
	{
		LATDbits.LATD0=0;
	}	
	
	if(data & 0x04)
	{
		LATDbits.LATD1=1;
	}	
	else
	{
		LATDbits.LATD1=0;
	}	
	
	if(data & 0x08)
	{
		LATCbits.LATC5=1;
	}	
	else
	{
		LATCbits.LATC5=0;
	}	
	
	if(data & 0x10)
	{
		LATCbits.LATC4=1;
	}	
	else
	{
		LATCbits.LATC4=0;
	}	
	
}

pointer.jpg
 
Last edited:

@jayanth.devarayanadurga

still didnt get.
but (void*) solved my problem.

New problem is pointer pointing to somewhere else i attach my code and image take a look at it
 

i already post my code and yes i initialize pointer in main take a look at it.
compiler is mplab c for pic18f version 3.40
 

What are you doing here?

Code C - [expand]
1
title_ptr = ((unsigned int*)(&str1[0]));



title_ptr is a pointer which expects a left value or address of a unsigned int type variable. str[] is a unsigned char variable. You are type casting address of str[0] to unsigned int*.

I think you have to typecast the variable and then get its address.


Code C - [expand]
1
title_ptr = &(unsigned int*)(str[0]);



str[0] is typecasted from unsigned char to unsigned int* (unsigned int pointer) and then address of that is assigned to title_ptr.



Code C - [expand]
1
title_ptr = title_row(title_ptr);

should be changed to

Code C - [expand]
1
title_ptr = title_row(&title_ptr);



title_row() returns a pointer and expects a left value as argument. you were passing right value as argument.



Code C - [expand]
1
2
3
4
5
6
title_ptr = title_row(&title_ptr);  
        second_ptr = second_row(&second_ptr);
        third_ptr = second_row(&second_ptr);
        fourth_ptr = second_row(&second_ptr);
        fifth_ptr = second_row(&second_ptr);
        sixth_ptr = second_row(&second_ptr);

 
Last edited:

@jayanth.devarayanadurga
thnks for reply,

i'll check it at night today and post the result.
 

What are you doing here?

Code C - [expand]
1
title_ptr = ((unsigned int*)(&str1[0]));



title_ptr is a pointer which expects a left value or address of a unsigned int type variable. str[] is a unsigned char variable. You are type casting address of str[0] to unsigned int*.

I think you have to typecast the variable and then get its address.


Code C - [expand]
1
title_ptr = &(unsigned int*)(str[0]);



str[0] is typecasted from unsigned char to unsigned int* (unsigned int pointer) and then address of that is assigned to title_ptr.



Code C - [expand]
1
title_ptr = title_row(title_ptr);

should be changed to

Code C - [expand]
1
title_ptr = title_row(&title_ptr);


You got it all screwed up. The original version is the correct C syntax in both cases.
 

@FvM
i checked it but there is syntax error.
compiler didnt accept the
Code:
 tittle_ptr=&((unsigned int*)str1[0])
due to "&" compiler says syntax error.
can u tell me where am i wrong?
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top