Facebook
From Tiny Sheep, 5 Years ago, written in Plain Text.
This paste is a reply to Re: Untitled from Obese Lion - go back
Embed
Viewing differences between Re: Untitled and Re: Re: Untitled
#include 
int main(int argc, char *argv[])
{
 int numbers[4] {0};
 char name[4] = {'a'};
 
0;
 
// first, print them out raw
 printf("numbers: %d %d %d %d\n",
 numbers[0], numbers[1],
 numbers[2], numbers[3]);
 printf("name each: %c %c %c %c\n",
 name[0], name[1],
 name[2], name[3]);
 printf("name: 
go through each string in argv
 // why am I skipping argv[0]?
 for(i = 1; i < argc; i++) {
 printf("arg %d: 
%s\n", name);
 
i, argv[i]);
 }
 
// setup the numbers
 numbers[0] 
let's make our own array of strings
 char *states[] 
1;
 numbers[1] = 2;
 numbers[2] = 3;
 numbers[3] 
{
 "California", "Oregon",
 "Washington", "Texas"
 };
 int num_states 
= 4;
 // setup the name
 name[0] 
for(i 'Z';
 name[1] = 'e';
 name[2] = 'd';
 name[3] = '\0';
 // then print them out initialized
 printf("numbers: %d %d %d %d\n",
 numbers[0], numbers[1],
 numbers[2], numbers[3]);
 printf("name each: %c %c %c %c\n",
 name[0], name[1],
 name[2], name[3]);
 // print the name like a string
 printf("name: 
0; i < num_states; i++) {
 printf("state %d: 
%s\n", name);
 // another way to use name
 char *another = "Zed";
 printf("another: %s\n", another);
MAIN
PREVIOUS
NEXT
HELP
Follow
@lzsthw
 printf("another: %s\n", another);
 printf("another each: %c %c %c %c\n",
 another[0], another[1],
 another[2], another[3]);
i, states[i]);
 }
 return 0;
}