c - Error "'strcpy' makes pointer from integer without a cast" -


struct phaseshiftpin {     int _psppin_index;      //psp = phase shift pin     int _pspvalue;     char _pspname[512]; }; struct phaseshiftpin *_phaseshiftpin[500000]; int p3int = 0; strcpy ( _phaseshiftpin[i]->_pspvalue, p3int ); 

the above code part of full code. when compiled full program happened error strcpy' makes pointer integer without cast @ line

strcpy ( _phaseshiftpin[i]->_pspvalue, p3int ); 

i have referred post @ here makes pointer integer without cast strcpy after tried use strncpy , follow method showed in post still fail in compilation.hope can guide me problem.thanks.

if @ definition of strcpy can see

char *strcpy(char *dest, const char *src); 

but _phaseshiftpin[i]->_pspvalue integer , p3int also.

you can use memcpy

void *memcpy(void *dest, const void *src, size_t n);  strcpy ( &(_phaseshiftpin[i]->_pspvalue), &(p3int), sizeof(p3int) ); 

or said in comment

_phaseshiftpin[i]->_pspvalue =  p3int; 

if try copy p3int _phaseshiftpin[i]->_pspvalue


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -