A
arnuld
#include <stdio.h>
enum { ARRSIZE = 50 };
int main(void)
{
char* p = "This is comp.lang.c";
char arrc[] = "This is comp.lang.c";
printf("p = %s\n", p);
printf("arrc = %s\n", arrc);
return 0;
}
============= OUTPUT =============
[arnuld@dune programs]$ gcc -std=c99 -pedantic -Wall -Wextra string.c
[arnuld@dune programs]$ ./a.out
p = This is comp.lang.c
arrc = This is comp.lang.c
[arnuld@dune programs]$
May of my colleagues use char* p method, while I always use char arrc
[]. I can see both are legal but which one s preferred/recommended
way. (like using #include <conio.h> is also legal but I don't think
its recommended)
enum { ARRSIZE = 50 };
int main(void)
{
char* p = "This is comp.lang.c";
char arrc[] = "This is comp.lang.c";
printf("p = %s\n", p);
printf("arrc = %s\n", arrc);
return 0;
}
============= OUTPUT =============
[arnuld@dune programs]$ gcc -std=c99 -pedantic -Wall -Wextra string.c
[arnuld@dune programs]$ ./a.out
p = This is comp.lang.c
arrc = This is comp.lang.c
[arnuld@dune programs]$
May of my colleagues use char* p method, while I always use char arrc
[]. I can see both are legal but which one s preferred/recommended
way. (like using #include <conio.h> is also legal but I don't think
its recommended)