Skip to main content

Thread: Why can't I print the 1st charachter of an array?


i want print first carachter of array. folowing code results in segmetation fault....
code:
#include <stdio.h>    main()    {  char s[] = "george sss";  printf("%s",s[1]);  }
also, in order create string, can this:
code:
char string;
?

quote posted stamatiou view post
[/code]also, in order create string, can this:
code:
char string;
?
strings nothing arrays of characters, here, declare 1 single char.

think segfault there because did not null terminated string.
add "/0" end of it.
, should declare main return int.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk Why can't I print the 1st charachter of an array?


Ubuntu

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support