简体   繁体   中英

Cast from Pointer to Pointer C++

would appreciate if I get pointer to following line of code

Char fileName[100] ;

strncpy(static_cast<Char *>( fileName),static_cast<const Char *>(getCurrentUser()),Int32(ML_STRING_SIZE));

I get Lint error: Cast from Pointer to Pointer. If I cast without static it throws error as C-style cast. If I do not use any cast

strncpy(( fileName),(getCurrentUser()),Int32(ML_STRING_SIZE));   it throws 
array type passed to function expecting a pointer

I'm not sure how to fix it.

Here is the fix.

strncpy(( &fileName[0]),(getCurrentUser()),UInt32(ML_STRING_SIZE));
  1. First agrument &fileName[0] ++ DreamLax
  2. Second argument returns const char* so no need to cast
  3. Third argument should be unsigned int.

All three together solved the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM