Skip to main content

Thread: C program How does this work?


hai all,
i'm in class think start writing shells kernel in bit. example code mentioned in class shown bellow, takes number of arguments including program name, , lists them in stdout. here example: $ ./a.out cat dog
0: ./a.out
1: cat
2: dog

great. thats expected.
got curious else can put in there, , how arguments processed, put stuff in , got:
$ ./a.out '' $pwd `touch me` $foobar `touch bobs lies` sluth ~ '"~' 'load'
0: ./a.out
1:
2: /home/j
3: sluth
4: /home/j
5: "~
6: load

, ended files me, bobs, , lies
shell assume processing not whitespace, other characters. & sends program background, shell script, , * lists sorts of stuff, of seems non-sense. shell processing program arguments. white space how getting parsed, , arguments arent counting arguments parser. of other output seems plain strange. happens when pass program ./a.out *
similarly, put $* in shell , got:
2011.jpg: command not found

whats going on here?
shell doing these characters?


http://publications.gbdirect.co.uk/c...s_to_main.html
code:
#include <stdlib.h>  #include <stdio.h>  int main( int argc, char ** argv){  	  	int i;  	for (i=0; i<argc; i++) {  		printf("%d: %s  \n", i, argv[i] );  	}    	return 0;  }

this has nothing c.

here: http://tldp.org/ldp/abs/html/internalvariables.html
aslo understand differences of bash when give "string" or 'string' or string (i.e no speechmarks)


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk C program How does this work?


Ubuntu

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account