Beginner C programming questions
Posted on 2003-02-22
I'm doing a school project. I am not very familiar with C, especially I never program in Unix C with gcc.
Here's my questions:
1. Can the main function's arguments be changed. Instead of int argc, char *argv, can I change it to something like int k, char flag, char *filename?
2. In my project, the description said, after processing, the output should be written to stdout. What's stdout? Is it the screen? (I'm programming in Unix using gcc)
3. Can someone great in programming C show me some sample code on how to do something like this: Read a input file line by line, breaking each line down to individual words, so I can do some analysis for each line that's broken down to token. Then I write changed code for each line in the input file to the output.
4. A question about strtok function: if I have a string S = "This is a string", then I use lines:
char *word1, *word2, *word3;
word1 = strtok(S, " ");
word2 = strtok(S, " ");
word3 = strtok(S, " ");
would word 1 2 3 has contains the token This; is; a?
Can you please show me some example on how to use strtok or other functions to break down a line of code into tokens that I can examine and use?
Thank you very much.