File tree Expand file tree Collapse file tree 11 files changed +125
-0
lines changed
Expand file tree Collapse file tree 11 files changed +125
-0
lines changed Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+ #include <string.h>
3+ #include <stdlib.h>
4+ const char * u2word (int u );
5+ int main (){
6+ int a = 0x52B3 ;
7+ printf ("%s\n" ,u2word (a ));
8+ }
9+ const char * u2word (int u ){
10+ char * temp = (char * )malloc (sizeof (int ));
11+ sprintf (temp ,"%X" ,u );
12+ printf ("\\u%s\n" ,temp );
13+ temp [0 ]= '\\' ;
14+ temp [1 ]= 'u' ;
15+ return temp ;
16+ }
Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+ #include <limits.h>
3+
4+ int main (){
5+ printf ("One Byte is %d bit\n" ,CHAR_BIT );
6+
7+ printf ("The min of signed char is %d\n" ,SCHAR_MIN );
8+ printf ("The max of signed char is %d\n" ,SCHAR_MAX );
9+ printf ("The max of unsigned char is %u\n" ,UCHAR_MAX );
10+
11+ printf ("The min of signed short is %d\n" ,SHRT_MIN );
12+ printf ("The max of signed short is %d\n" ,SHRT_MAX );
13+ printf ("The max of unsigned short is %u\n" ,USHRT_MAX );
14+
15+ printf ("The min of signed int is %d\n" ,INT_MIN );
16+ printf ("The max of signed int is %d\n" ,INT_MAX );
17+ printf ("The max of unsigned int is %u\n" ,UINT_MAX );
18+
19+ printf ("The min of signed long is %ld\n" ,LONG_MIN );
20+ printf ("The max of signed long is %ld\n" ,LONG_MAX );
21+ printf ("The max of unsigned long is %lu\n" ,ULONG_MAX );
22+
23+ printf ("The min of signed long long is %lld\n" ,LLONG_MIN );
24+ printf ("The max of signed long long is %lld\n" ,LLONG_MAX );
25+ printf ("The max of unsigned long long is %llu\n" ,ULLONG_MAX );
26+
27+ }
Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+ #include <stdlib.h>
3+ int main (){
4+ int * a = (int * )malloc (sizeof (int ));
5+ * a = 4 ;
6+ printf ("a:%p\n" ,a );
7+ {
8+ free (a );
9+ int * b = (int * )malloc (sizeof (int ));
10+ printf ("a:%p\n" ,a );
11+ printf ("b:%p\n" ,b );
12+ }
13+ printf ("%d\n" ,* a );
14+ }
File renamed without changes.
Original file line number Diff line number Diff line change 1+ CMAKE_MINIMUM_REQUIRED (VERSION 2.9)
2+ PROJECT (ONEBOT_C)
3+ INCLUDE_DIRECTORIES (./include )
4+ AUX_SOURCE_DIRECTORY (./src DIR_SRC)
5+ ADD_EXECUTABLE (./bin ${DIR_SRC} )
Original file line number Diff line number Diff line change 1+
2+ rm -rf build
3+ mkdir build
4+ cd build
5+ cmake .. -G " MinGW Makefiles"
6+ make
7+ ./bin
Original file line number Diff line number Diff line change 1+ #ifndef _str_h
2+ #define _str_h
3+ #include <cstdio>
4+ #include <cstdlib>
5+ #include <cstring>
6+ void strval (char * * str1 ,const char * str2 ,int type );
7+ #endif
Original file line number Diff line number Diff line change 1+ #include " ../include/str.h"
2+ void strval (char **str1,const char *str2,int type){
3+ switch (type)
4+ {
5+ case 1 : {
6+ *str1=(char *)malloc (strlen (str2+1 ));
7+ sprintf (*str1," %s" ,str2);
8+ printf (" case 1 :%s\n " ,*str1);
9+ break ;
10+ }
11+ case 2 : {
12+ *str1 = (char *)realloc (*str1,strlen (*str1)+strlen (str2)+1 );
13+ sprintf (*str1," %s%s" ,*str1,str2);
14+ printf (" case 2 :%s\n " ,*str1);
15+ }
16+ break ;
17+ case 3 : {
18+ free (*str1);
19+ *str1=(char *)malloc (strlen (str2+1 ));
20+ sprintf (*str1," %s" ,str2);
21+ printf (" case 3 :%s\n " ,*str1);
22+ break ;
23+ }
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ #include " ../include/head.hpp"
2+ int main (){
3+ struct head_link *test1=add ();
4+ test1->type [0 ]=1 ;
5+ strval (&(test1->name )," hello " ,1 );
6+ strval (&(test1->name )," world" ,2 );
7+ strval (&(test1->name )," goodbye world" ,3 );
8+ printf (" name:%s\n num:%d\n " ,(test1->name ),(test1->type [0 ]));
9+ return 0 ;
10+ }
11+
You can’t perform that action at this time.
0 commit comments