Posts

C - We Should Never Use Function Sizeof to Calculate Size of a Pointer Which Points to String

Code: #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { char arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; char *str = "1234567890"; printf("Size of arr is %d\n", sizeof(arr)); printf("Size of *arr is %d\n", sizeof(*arr)); printf("String length of arr is %d\n", strlen(arr)); printf("Size of str is %d\n", sizeof(str)); printf("Size of *str is %d\n", sizeof(*str)); printf("String length of str is %d\n", strlen(str)); return 0; } Output: Size of arr is 10 Size of *arr is 1 String length of arr is 9 Size of str is 8 Size of *str is 1 String length of str is 10

Windows - Fail to Read and Format SD Card But See It in Disk Management

After I used Win32diskimager to write my SD card, card failed to be read on Windows 10 but Linux. It can be found in disk management of Windows 10, but it can't be formatted and pop up dialog which showed "System cannot find the file specified." To read, try assigning drive letter to the card if we do not need formatting the card. To format, use DISKPART. Warning: Choose disk number carefully to avoid deleting important parts of computer. Cleaning and formatting card, storage comes back.

CoppeliaSim - Keyboard Input, Status Bar, Console Window, and Nil

Image
According to http://www.forum.coppeliarobotics.com/viewtopic.php?f=9&t=1751 and http://www.forum.coppeliarobotics.com/viewtopic.php?f=9&t=5299 in CoppeliaSim forum, we can know that string.byte('A') represents character 'A' and auxiliaryData[1] stores keyboard input of simGetSimulatorMessage(). The dialog at bottom of CoppeliaSim is called status bar, while console window is hidden by default. By changing user setting, you can see it. Warning: Closing console window leads to shutting down software CoppeliaSim itself. Use simAddStatusbarMessage(auxiliaryData[1]) to print input message on status bar, then use print(auxiliaryData[1]) to print input message on console window. You can check script of object naked car in folder example to know how to deal with keyboard input. For function reference, visit http://www.coppeliarobotics.com/helpFiles/en/apiFunctions.htm#simGetSimulatorMessage . Sometimes functions return value nil which means nothing. It i...

ShareX - Set Up Screen Recorder Step by Step

Image
When you try to find GPL software of screen recording, you may bump into one called CamStudio on SourceForge. Unluckily, for some reason, some people can't use them record video with sound and its environment setting is complicated. I can't, either. 😕 Fortunately, I found this one after fail on CamStudio. It's ShareX that also use GPL. Here I gonna teach you how to set up the environment for screen recording. 1. First, go to "Task settings"→"Screen recorder"→"Screen recording options". 2. Second, click "Download" and click "Install recorder devices". 3. Third, refresh and choose "GDI grab" in video source and "virtual-audio-capturer" in audio source. Do not choose "screen-capture-recorder" because it may cause incorrect position of cursor during recording for some reason. 4. Lastly, the key point is here. The ffmpeg file you installed previously would probably NOT work. Yo...