Thread: Printing charcter by character

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    151

    Printing charcter by character

    Hi.....
    I have to parse through an input XML file line-by-line, character-by-character and find if closing HTML tags are present for every opening HTML tag.

    Code:
    MAIN program:
    	while (scanf("%s", code) != EOF)
    	{
    		i=0;
    		length = strlen(code);
    		while (i < strlen(code))
    		{
    			c=code[i];
    			if (c == '<')
    			{
    	                 j=0;
    
                                     do
    	                         {
    					c=code[i];
    					element[j]=c;
    					++i;
    					j++;
    				}while(c!='>');
    
    				c=code[++i];
    
    				element[j] = '\0';
    
    
    				if (element[1] == '/')
    				{
    					l=element[2];
    					length = strlen(element);
    					for (k=0;k<=length-4;k++)
    					{
    						check[k]=element[l++];
    					}
    					check[k] = '\0';
    					/*Function passsed tho process the element()*/
    					printf("%s",element);
    
    				}
    
    				else
    				{
    					l=element[1];
    
    					length = strlen(element);
    					for (k=0;k<=length-3;k++)
    					{
    						check[k]=element[l++];
    
    					}
    					check[k]='\0';
    					/*Function passsed tho process the element()*/
    					printf("%s",element);
    				}
    
    			}
    			else
    			{
    				putchar(c);
    				c=code[++i];
    			}
    
    		}
    	}
    When printing to the output I find that any character that is printed just after '>' character without any spaces will not be printed to the output. Also no spaces from the input text is printed to the output.

    Please help
    Last edited by Ron; 06-15-2008 at 08:08 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Remove character from string
    By nooksooncau in forum C Programming
    Replies: 11
    Last Post: 06-05-2006, 09:37 AM
  2. about wide character and multiple byte character
    By George2 in forum C Programming
    Replies: 3
    Last Post: 05-22-2006, 08:11 PM
  3. pipe
    By smart girl in forum C Programming
    Replies: 4
    Last Post: 04-30-2006, 09:17 AM
  4. need help relating printing?
    By omarlodhi in forum Linux Programming
    Replies: 0
    Last Post: 03-03-2006, 04:46 AM
  5. Printing a Character from Binary
    By SavesTheDay in forum C Programming
    Replies: 6
    Last Post: 02-19-2002, 02:35 PM