Thread: I dont get this working on gcc it works fine in windows

  1. #1
    wise_ron wise_ron's Avatar
    Join Date
    May 2006
    Posts
    75

    cdalten i need your help check this out or someone that can help me... thanks

    Hi everyone i like your help with this program. it runs good on windows but i want it to work in linux gcc. The add function works but when ti comes to the save, find, print, load etc...
    they dont work as they suppose to. I have been messing with this a while and iam totally stuck and dont know what to do

    i would really apreciate your help.
    thanks for your help and time

    Wise Ron
    Last edited by wise_ron; 05-07-2006 at 10:38 PM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    No one is interested in debugging 100's of lines of horribly buggy code for you.

    In fact...
    http://cboard.cprogramming.com/showthread.php?t=78732
    You've not addressed all the issues which I listed here.

    Until you replace all your gets() calls with fgets() calls, and remove ALL your fflush(stdin) calls, I'm not even going to look at your code.

    Additionally, commenting out whole functions (and then posting them anyway) does nothing but clog up the board.

    Unfortunately, you're now paying the price of learning an implementation before learning the language. All those comfy assumptions which you used to get away with in DOS land do not apply everywhere else.
    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.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Let me put it another way - do you want to learn how to write code which always works regardless of which platform you happen to be using, or are you looking for a one-time fix ?
    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.

  4. #4
    Registered User
    Join Date
    Jan 2006
    Location
    Berkeley, Ca
    Posts
    195
    Portability is just a passing fad.

  5. #5
    wise_ron wise_ron's Avatar
    Join Date
    May 2006
    Posts
    75

    i get 4 erros changing from gets() to fgets()

    I try to fallow what you sayed, thanks. I will stick to gcc thats what i need the code running on gcc. Windows is ok , but sometimes it sucks.

    This are the errors i get when i change the gets() for the fgets().
    I put in all of the files i change the faloowring: fgets(buffer, sizeof(buffer), stdin);

    can you guys help me out i dont know what to do...
    Thanks a lot

    Ron

    Code:
    user@XANYQIO8N50:~/TOMS/onefile$ gcc -o good good.c
    good.c: In function `main':
    good.c:592: error: too few arguments to function `fgets'
    good.c:592: error: called object is not a function
    good.c:664: error: too few arguments to function `fgets'
    good.c:664: error: called object is not a function
    good.c:716:2: warning: no newline at end of file
    user@XANYQIO8N50:~/TOMS/onefile$

  6. #6
    Registered User
    Join Date
    Apr 2006
    Posts
    9
    i ran this with mingw and found quite a few problems that you made and got it running now.

    but you need to still make some changes to really get it to work on unix cause i believe unix is more strict on coding than windows is.

    check out this site and youll find some help with Unix

    sites down right now but check back later
    http://www.iso-9899.info/

  7. #7
    wise_ron wise_ron's Avatar
    Join Date
    May 2006
    Posts
    75

    Thanks to you all i have improve. I have somethings i want to fix

    Iam new to this forum and new to c programmin. Help me if you can
    The program compiles and it works ok until certain extend. This are some few things that i see the program is not working as it suppose too.

    1. The save function or when i save a new question and the answers. It prints "write operation completed sucessfully", but underneath it prints the menu again and it says "illegal command". Question: how can i make that second menu option appear and the illegal comand print, is not suppose to work like that

    2. Almos the samethings happens with the load function. When i try to retrieve the data from the question.dat.

    3. When i l select print in the menu. It gives me the result null for question and the answers.
    How can i make this improve and work correctly

    here is the souce code in the attachment. This is what i have so far.

    Thanks for your help, iam learning fast and alot.

  8. #8
    wise_ron wise_ron's Avatar
    Join Date
    May 2006
    Posts
    75

    Need help! comp;iling with linux gcc

    Salem i have done what you told me what to do next.

    Thanks

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    > what to do next.
    Do some more testing - what works, what doesn't.

    Code:
    $ gcc -W -Wall -O2 foo.c
    foo.c: In function `search_entry':
    foo.c:266: warning: unused variable `i'
    foo.c: In function `main':
    foo.c:468: warning: unused variable `filename'
    foo.c:624:2: warning: no newline at end of file
    foo.c: At top level:
    foo.c:464: warning: unused parameter 'argc'
    foo.c:464: warning: unused parameter 'argv'
    foo.c:229: warning: unused parameter 'sort_criteria'
    foo.c: In function `sort_test':
    foo.c:383: warning: 'str_sort' might be used uninitialized in this function
    foo.c:384: warning: 'str_sort_next' might be used uninitialized in this function
    Those "might be used uninitialized" need to be looked at.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. This works fine with IP 127.0.0.1 but fails with my REAL IP.
    By azjherben in forum Networking/Device Communication
    Replies: 15
    Last Post: 05-19-2009, 10:28 PM
  2. Compile issue in g++, works fine in VS
    By bean66 in forum C++ Programming
    Replies: 4
    Last Post: 04-20-2009, 09:48 AM
  3. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  4. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM
  5. My computer works just fine
    By Betazep in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 07-02-2002, 08:51 AM