Code explanation

This is a discussion on Code explanation within the C Programming forums, part of the General Programming Boards category; Hello everybody i need to understnd this piece of code can you guys pelase help me i am stuck thank ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    2

    Code explanation

    Hello everybody i need to understnd this piece of code can you guys pelase help me i am stuck thank you very much haad

    Code:
    #include <stdio.h>
    #include <string.h>
    
    int main(int argc, char *argv[], char *env[])
    {
    	char *token = NULL;
    	char colour1[300] = "";
    	char colour2[300] = "";
    	char flag[300] = "";
    	int wide = 5;
    	int high = 5;
    	int columns = 5;
    	int rows = 5;
    
    	token = (char *) strtok(argv[1],":");
    	strcpy(colour1,token);
    	token = (char *) strtok(NULL,":");
    	strcpy(colour2,token);
    	token = (char *) strtok(NULL,":");
    	wide = atoi(token);
    	token = (char *) strtok(NULL,":");
    	high = atoi(token);
    	token = (char *) strtok(NULL,":");
    	strcpy(flag,token);
    	printf("Content-type:text/html\n\n");
    	printf("<html>\n");
    	printf("<body>\n");
    	printf("<center>\n");
    	printf("<table bgcolor=\"%s\" border=2>\n",colour2);
    	for(rows=1;rows<=high;rows++)
    	{
    		printf("<tr>\n");
    		for(columns=1;columns<=wide;columns++)
    		{
    			if(columns==5 || rows==5)
    				printf("<td bgcolor='%s'><h6>%s</h6></td>\n",colour2,flag);		
    			else
    				printf("<td bgcolor='%s'><h6></h6></td>\n",colour1);
    		}
    		printf("</tr>\n");
    	}
    	printf("</table>\n");
    	printf("</body>\n");
    	printf("</html>\n");
        return 0;
    }

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    2
    whatever

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,647
    MK27 was kind enough to ask you to improve on your question so others can help you better, but since you want to display this attitude...

    Read about and follow the homework policy. Or else.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Kong_Han_Dao View Post
    whatever
    I wasn't being facetious. Here:
    Quote Originally Posted by How to ask questions...
    Volume is not precision

    You need to be precise and informative. This end is not served by simply dumping huge volumes of code or data into a help request. If you have a large, complicated test case that is breaking a program, try to trim it and make it as small as possible.

    This is useful for at least three reasons. One: being seen to invest effort in simplifying the question makes it more likely you'll get an answer, Two: simplifying the question makes it more likely you'll get a useful answer. Three: In the process of refining your bug report, you may develop a fix or workaround yourself.
    If you have a specific question, ask it. If you expect someone to sit down and annotate 50 lines of code for you -- good luck (it might happen).
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Proposal: Code colouring
    By Perspective in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 05-14-2007, 07:23 AM
  2. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  3. Code Explanation
    By dmkanz07 in forum C Programming
    Replies: 1
    Last Post: 03-27-2007, 08:24 PM
  4. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 03:17 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21