Plz help,a STRANGE problem in C

This is a discussion on Plz help,a STRANGE problem in C within the C Programming forums, part of the General Programming Boards category; pls help,i've encountered a strange prblm wid RUNning of my programsg in C. the prblm is that the functions that ...

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    8

    Plz help,a STRANGE problem in C

    pls help,i've encountered a strange prblm wid RUNning of my programsg in C.
    the prblm is that the functions that have been created and r included in d program by me are nt getting executed nd d compiler is nt giving any error,for example dis is what is hapning when i run dis code
    Code:
    #include<stdio.h>
    #include<conio.h>
    void main()
    {clrscr() ;
    printf(''hello world !'') ;
    void name_function () ;
    getch() ;
    }
    void name_function()
    {
    printf(''\n i am in name_function'') ;
    }
    . . . . . . . . . . . . . . . . . . Now d program compiles n runs successfuly BUT instead of giving d desired ouput as 'hello world !
    i am in name_function'
    it gives only d following output
    'hello world !',thus totaly omitting my created function. . . .dis is happening wid al my prgrms where m using functions pls help !

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    '' is not "


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,447
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Jul 2010
    Posts
    8
    I dnt need jokes here,i hv a prblm nd i hv stated it above,if u knw d solution den reply else dnt creat unnecessary rubble here !
    -Himani sharma,IAS.
    secretary,Dept of Technical edn,UP

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,422
    quzah already gave you a correct answer, though there are other potential problems. Admittedly, the colours make it look like a flag or something, but the point is that two single quotes is not a double quote.
    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

  6. #6
    Registered User
    Join Date
    Jul 2010
    Posts
    8
    @laserlight-thanx fr ur reply,i will certainly go through the suggestions givn by u.
    thanx.

  7. #7
    Registered User
    Join Date
    Jul 2010
    Posts
    8
    @laserlight -thanx fr ur reply,i will certainly go through ur suggestions.
    thnx

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by hkbiet View Post
    I dnt need jokes here,i hv a prblm nd i hv stated it above,if u knw d solution den reply else dnt creat unnecessary rubble here !
    -Himani sharma,IAS.
    secretary,Dept of Technical edn,UP
    Plz save this kind of english/gibberish for your social networking "krew" and give us C "soldar's", very plain old English with words all spelled out.

    To put it mildly "we are NOT amused", by the baby-version of English.

  9. #9
    Registered User
    Join Date
    Jul 2010
    Posts
    8
    @ADAK-please do not mind it,it was my mistake and i am sorry for that.
    PLEASE READ my problem up there and try to help me.
    thank you

  10. #10
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Your problem has been answered twice already, but one more time:

    In the printf() statements, you have used two SINGLE quotation marks, instead of the correct, ONE double quotation mark:

    Code:
    printf(''\n i am in name_function''); 
    
    //instead of:
    
    printf("\n i am in name_function");
    They look the same, but try to delete just one quotation mark from the top version (yours), and then try to do the same thing to the second version (mine).

    You'll see the difference.

  11. #11
    Registered User
    Join Date
    Jul 2010
    Posts
    8
    @ADAK-i hav typed the code above via mobile hence i had to use two single quotes instead of a double quote as my mobile character set has'nt got a double quote in it,but on my computer i have correctly used double quotes there as you have mentioned.since i do nt have a internet connection on my pc hence i hv to use my mobile(gprs),
    i request u to please c my problem again,none of the functions that i hav made are working in the code nd d compiler is also nt giving ny error,please read my problem again. . . .
    .

  12. #12
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,422
    Sigh. Fair enough. The problem is that you are declaring the name_function in the main function. You should be declaring it above the main function, and then calling it in the main function.
    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

  13. #13
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,447
    > i hav typed the code above via mobile
    You're basically wasting everyone's time then!

    Stop posting until you're back at your computer and can copy/paste your ACTUAL code into a message.

    You might also be able to compose a decent English post as well, rather than trying to keep with the SMS speak.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  14. #14
    Registered User
    Join Date
    Jul 2010
    Posts
    8
    @laserlight-Thank you very much,as you pointed out the real flaw in my code and the way functions ought to be declared,finally by implementing the changes as mentioned by you my program(s) are finally working properly.
    thank you again. . . .keep the good work going.
    i would also thank every body else here for thier kind and generous support.
    may you all succed in your endeavours.
    good bye .

  15. #15
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    Code:
    void main()                 // it's int main(void) 
    {
    clrscr() ;                     /* avoid non-standard function
    printf(''hello world !'') ;
    void name_function () ;        // this is function prototype. *not* function call! 
                                         // GOT IT??! 
     
    getch() ;                    /* non-standard function */
    }
    void name_function() 
    {
    printf(''\n i am in name_function'') ;
    }
    You should be able to figure out the answer yourself.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange problem with GETLINE
    By wco5002 in forum C++ Programming
    Replies: 13
    Last Post: 07-07-2008, 09:57 AM
  2. Strange problem
    By G4B3 in forum C Programming
    Replies: 6
    Last Post: 05-14-2008, 02:07 PM
  3. Strange problem with classes in header files
    By samGwilliam in forum C++ Programming
    Replies: 2
    Last Post: 02-29-2008, 03:55 AM
  4. Extremely strange "delete" problem
    By dr_jaymahdi in forum C++ Programming
    Replies: 4
    Last Post: 10-21-2007, 09:06 PM
  5. Strange problem with fts_open call
    By jhopper in forum C Programming
    Replies: 0
    Last Post: 02-25-2002, 11:01 PM

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