C notes
From OriWiki
combine with Python
executing a shell command
#include <stdio.h>
#include <stdlib.h>
int main(void) {
printf("hi\n");
system("ls");
return 0;
}
char* arr Vs. char arr[]
#include <stdio.h>
void foo(char p1[], char *p2) {
printf("parameter strings: p1-%s, p2-%s, sizeof(p1)-%d, sizeof(p2)-%d\n",p1,p2,sizeof(p1),sizeof(p2));
++p1; ++p2;
printf("after ++p1; ++p2: p1-%s, p2-%s, sizeof(p1)-%d, sizeof(p2)-%d\n",p1,p2,sizeof(p1),sizeof(p2));
// p1 and p2 seems to have the same pointer type
// int a=p1; // warning: initialization makes integer from pointer without a cast
}
int main(void) {
char str[] = {'h','e','l','l','o','\0'};
printf("str[] as variable: %s, sizeof: %d, address: %p\n",str,sizeof(str),str);
//++str; //compilation error: str is not considered lvalue
foo(str,str);
// int a = str;// warning: initialization makes integer from pointer without a cast... hmmm... I wouldn't expect that
}

