Add some code about strings
This commit is contained in:
parent
58aa6aba6c
commit
8bb4bc8a64
1 changed files with 15 additions and 0 deletions
15
c_modern_approach/Strings/playground.c
Normal file
15
c_modern_approach/Strings/playground.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <stdio.h>
|
||||
int main(void) {
|
||||
// String literal assigment
|
||||
char *p;
|
||||
/*Following statement does not copy string. It makes pointer p to point to first charachter of list of chars*/
|
||||
p = "abc";
|
||||
printf("%s\n\n", p);
|
||||
|
||||
// ---
|
||||
|
||||
// Subscripting
|
||||
char ch;
|
||||
ch = p[1];
|
||||
printf("%c\n", ch);
|
||||
}
|
Loading…
Reference in a new issue