Thread: Please tell me where my code is incorrect.

  1. #1
    Registered User
    Join Date
    Jan 2014
    Posts
    6

    Post Please tell me where my code is incorrect.

    [code]<br>
    #include &lt;stdio.h&gt;<br>
    #include &lt;stdlib.h&gt;<br>
    <br>
    <br>
    int main()<br>
    {<br>
    &nbsp;&nbsp; &nbsp;char s[]="C a of";<br>
    &nbsp;&nbsp; &nbsp;char t[]="is philosophy life";<br>
    &nbsp;&nbsp; &nbsp;char u[40];<br>
    &nbsp;&nbsp; &nbsp;char ........=s,*tt=t,*uu=u;<br>
    &nbsp;&nbsp; &nbsp;while(........||*tt)<br>
    &nbsp;&nbsp; &nbsp;{<br>
    &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;while(........)<br>
    &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{<br>
    &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if((*uu++ = ........++)=='')<br>
    &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br>
    &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}<br>
    &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;while(*tt)<br>
    &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{<br>
    &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp%
    Last edited by Sonam Agarwal; 01-09-2014 at 05:24 AM.

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Perhaps you would get some help if you took the effort to ensure that your code posted properly.

  3. #3
    Registered User
    Join Date
    Jan 2014
    Posts
    6
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    
    int main()
    {
        char s[]="C a of";
        char t[]="is philosophy life";
        char u[40];
        char ........=s,*tt=t,*uu=u;
        while(........||*tt)
        {
            while(........)
            {
                if((*uu++ = ........++)=='')
                    break;
            }
            while(*tt)
            {
                if((*uu++ = *tt++)=='')
                    break;
            }
        }
        *uu='\0';
        puts(u);
    
    
        printf("Hello world!\n");
        return 0;
    
    
    }
    Sorry for the inconvenience.
    This is the correct code.
    Error it gives with gnu c++ compiler is: empty charater constant at line 14 and 19

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Well, that's because you have an empty character constant on lines 14 and 19. (In the posted example, they appear on lines 15 and 20 for whatever reason.) You need to decide what character you meant that to be, and put it there. I suspect, just based on rearranging the words into a sentence, that you're looking for a space character.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Value is incorrect??
    By Myca in forum C Programming
    Replies: 3
    Last Post: 02-11-2011, 10:20 AM
  2. My last incorrect code needs some help!!!
    By dotrunghai82 in forum C Programming
    Replies: 10
    Last Post: 11-16-2006, 04:47 PM
  3. Another incorrect code needs some corrections
    By dotrunghai82 in forum C Programming
    Replies: 1
    Last Post: 11-12-2006, 09:34 PM
  4. incorrect initialisation
    By s_siouris in forum C Programming
    Replies: 2
    Last Post: 09-13-2006, 07:26 AM
  5. Incorrect Input
    By CeeCee in forum C Programming
    Replies: 1
    Last Post: 11-26-2001, 12:25 PM