July 2015
Intermediate to advanced
380 pages
10h 15m
English
You can make an array of various types with the idea that a string and an array of bytes are the same thing. The next step is to do an array that has strings in it. We’ll also introduce your first looping construct, the for-loop, to help print out this new data structure.
The fun part of this is that there’s been an array of strings hiding in your programs for a while now: the char *argv[] in the main function arguments. Here’s code that will print out any command line arguments you pass it:
ex13.c
1 #include <stdio.h> 2 3 int main(int argc, char *argv[]) 4 { 5 int i = 0; 6 7 // go through each string in argv 8 // why am I skipping argv[0]?
Read now
Unlock full access