Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- char name[14] = "Bucky Roberts";
- printf("My name is %s \n", name);
- // you can access individual elements by using subscripts
- // in programming, all array start with 0, not 1
- name[2] = 'z';
- printf("My name is %s \n", name);
- // when you define an array and set its value on the same line, you don't need to say how many elements
- char food[] = "tuna";
- printf("I love to eat %s \n", food);
- // if you want to assign a new string to an array, you have to use strcpy()
- strcpy(food, "bacon");
- printf("I love to eat %s \n", food);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement