There is no direct function to convert a string to upper case or lower case in Linux C. Here we collect 2 functions from internet: #include <ctype.h> static char* Str2Upper(char *str)   {       if(str == NULL)         return NULL;         char *p = str;           while(*str)     {           *str = toupper(*str);           [Read More ...]

Our R&D Manager and senior system designer Mr. Mohamed gave us the following sample for a thread sleep in Linux. #define _POSIX_C_SOURCE 199309 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdint.h> #include <sys/time.h> #include <time.h> void mySleep() {   int32_t  retval   struct timespec  requestTm, remainTm;   retval = 0   requestTm.tv_sec = 0;   [Read More ...]

Dirty memory is not memory leak. Dirty memory has been released and can be re-allocate, but memory leak indicates the memory block has not released correctly  so the memory can not be re-allocated. from RedHad website: Dirty means "might need writing to disk or swap." Takes more work to free. Examples might be files that [Read More ...]

There are some embedded devices or products in the market which are using Linux. They need some special Linux commands, Here we list part of them, and maybe we will keep on update them if we find more: 1: copy file to Plug and Play device: # cp /usr/local/bin/scripts/menu.rss /tmp/usbmounts/sdb1/ copy menu.rss to a USB [Read More ...]

This sample code is for testing some data type border value using C union. Worked on Linux OS. #include #include int main(void) { union { unsigned long int lms; unsigned short shms[2]; unsigned char  bms [4]; } myms; myms.lms = 0; while (1) { printf(“long: %ld  short: %d  byte: %d\n”, myms.lms, myms.shms[0], myms.bms[0]); usleep(900); myms.lms++; [Read More ...]

© 2013 CodeEase.com Suffusion theme by Sayontan Sinha