If you receive a pointer pointing to the beginning of a char array as an argument as follows, I would like to know the number of elements of the char array using string_ptr.
void hoge(char*string_ptr){
// For char string [100]
// size of (string) / size of (char)
}
Not possible (so buffer overrun vulnerability still exists)
void hoge (char*string_ptr, size_t buffsize);
hoge() side should take memory dynamically
char*hoge(){
char*p = NULL;
for {
char*q = realoc(p,newsize);
if(q==NULL) {Error handling and escape;}
// Continue only if no errors have occurred
p=q;
take some action on p;
}
It is the responsibility of the caller to return p;//free().
}
1858 M2 Mac fails to install rbenv install 3.1.3 due to errors
1646 I want to run pyautogui without remote connection on Windows 10 in the cloud
1856 I want to connect to the webcam from WSL(ubuntu)
1699 Error in x, y, and format string must not be None
1721 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2025 OneMinuteCode. All rights reserved.