Thread: why won't this c progrom work

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    9

    why won't this c progrom work

    no program
    Last edited by bob_999; 01-08-2011 at 03:00 PM.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Dude....

    What exactly is the problem? What exactly is not working?

  3. #3
    Registered User \007's Avatar
    Join Date
    Dec 2010
    Posts
    179
    We don't have the time or ambition to go through that much code. Why not post the compiler's error message along with it?

  4. #4
    Registered User
    Join Date
    Jan 2011
    Posts
    9
    their are no compiler errors it just does not do wont I wont it to do like this if statment which is to display the membership fee but it will not work
    Code:
     	  /* Membership fee*/
    	  if ( Member.Membership == "Premium" ){
    
          printf ("Membership fee per annum: %d\n", Premium);
    }                      
          if ( Member.Membership == "Standard" ) {
    
          printf ("Membership fee per annum: %d\n", Standard);
    }
          if (Member.Membership == "Junior") {
    
    	   printf ("Membership fee per annum: %d\n", Junior);
    }
          else  
    {
           printf ("Unable to work out the membership fee!\n");
    }

  5. #5
    Registered User
    Join Date
    Jan 2011
    Posts
    9
    it just displays Unable to work out the membership fee!

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Read up on strcmp for how to compare 2 nullterminated strings with eachother.

  7. #7
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by bob_999 View Post
    their are no compiler errors it just does not do wont I wont it to do like this if statment which is to display the membership fee but it will not work
    Code:
          if ( Member.Membership == "Standard" ) {
    
           if (Member.Membership == "Junior") {
    C does not know how to do this.

    C does not have a built in string type that you can manipulate in that way. It does, however, have a large number of library routines that will treat a character array as a string and perform string-like operations for you. In this case you should be interested in stricmp()....

  8. #8
    Registered User
    Join Date
    Jan 2011
    Posts
    7
    Hold on Bob! There is hope, I'm working on a fix for you, just keep checking back.

  9. #9
    Registered User
    Join Date
    Jan 2011
    Posts
    9
    ok Lenna

  10. #10
    Registered User
    Join Date
    Jan 2011
    Posts
    7
    I'm almost done. I decided to re-write your source from scratch to accomplish the task. I'll be a few more minutes.

  11. #11
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Yeah, that's a great idea Lenna_Pengy; instead of letting Bob learn how to use strcmp, why don't you just go right ahead and rewrite his homework for him. New to programming forums, are we?

  12. #12
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Lenna_Pengy View Post
    I'm almost done. I decided to re-write your source from scratch to accomplish the task. I'll be a few more minutes.
    Make sure you don't just post that huge chunk of code here; keep the homework policy in mind. "Rewriting the code from scratch" doesn't really fit the purpose.

  13. #13
    Registered User
    Join Date
    Jan 2011
    Posts
    7
    Quote Originally Posted by rags_to_riches View Post
    Yeah, that's a great idea Lenna_Pengy; instead of letting Bob learn how to use strcmp, why don't you just go right ahead and rewrite his homework for him. New to programming forums, are we?
    I am rewriting his homework yes, but in a way that he has to learn it. I can see you're not very new to looking at membership details. Coincidentally this entire thread is about a program relating to membership details. Why not use your 1337 membership skills to help bob come to a solution rather than pick apart what I'm doing.

  14. #14
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Lenna_Pengy View Post
    I am rewriting his homework yes, but in a way that he has to learn it. I can see you're not very new to looking at membership details. Coincidentally this entire thread is about a program relating to membership details. Why not use your 1337 membership skills to help bob come to a solution rather than pick apart what I'm doing.
    Because neither rags_to_riches nor myself see any problem with the guidance that has already been provided by shakti and CommonTater which has pointed out the difficulty and suggested a method of fixing it, which were even posted before your "offer" of rewriting the code. Have you even read the rest of the thread?

  15. #15
    Registered User
    Join Date
    Jan 2011
    Posts
    7
    Quote Originally Posted by tabstop View Post
    Because neither rags_to_riches nor myself see any problem with the guidance that has already been provided by shakti and CommonTater which has pointed out the difficulty and suggested a method of fixing it, which were even posted before your "offer" of rewriting the code. Have you even read the rest of the thread?
    I am providing additonal guidance. I have read the rest of the thread. Have you also noticed that his source is written by 3 different programmers? XD

    Anyway! Here is the basic framework you'll want to use bob, you can modify it and expand it into what you need. This should help.

    Code:
    stt:
    cls
    admn$ = "admin"
    pw$ = "hello"
    
    '-------------------
    'whichever you prefer, integer or string, you could just use a basic parsing script though
    st1$ = st1%
    st2$ = st2%
    st3$ = st3%
    'st1 is premium
    'st2 is standard
    'st3 is junior
    
    
    st1% = 1 'premium
    st2% = 2 'standard
    st3% = 3 'junior
    
    '----membership stuff
    totalp% = 0
    totals% = 0
    totalj% = 0
    totalm% = 0 'total number of members
    
    
    '----------membership ID's
    mem1% = st1%
    mem2% = st2%
    mem3% = st3%
    mem4% = st2%
    mem5% = 
    
    '-------------
    'admin login-------------
    print "Admin login: "
    input A$
    print "Admin Pass: "
    input P$
    
    if P$ = pw$ and A$ = admn$ goto accepted
    if P$ <> pw$ and A$ <> admn$ goto stt
    '---------------------------
    
    'accepted login----------------
    accepted:
    cls 
    print "Welcome Bob!"
    ?
    print "what would you like to do?"
    print "1. View all premium members"
    print "2. View all standard members"
    print "3. View all junior members"
    print "4. look up member by ID"
    print "5. look members by name"
    print "6. Display all expiring memberships by month"
    
    input N$
    
    if N$ =1 goto prem
    if N$ =2 goto stan
    if N$ =3 goto jun
    if N$ =4 goto ID
    if N$ =5 goto nam
    if N$ =6 goto ex
    if N$ <> "1" or N$ <> "2" or N$ <> "3" or N$ <> "4" or N$ <> "5" or N$ <> "6" goto accepted
    
    '-------this is for our premium members
    
    prem:
    cls
    color 15
    print "Currently displaying all Premium members"
    print
    if mem1% = st1% gosub 1mem
    if mem2% = st1% gosub 1mem
    if mem3% = st1% gosub 1mem
    if mem4% = st1% gosub 1mem
    if mem5% = st1% gosub 1mem
    Using a layout similar to this and flags for just about everything, you should be able to write your code around this. Just a simple and very incomplete indexing system. I would suggest using BCX for compiling when you finish for C.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 07:48 PM
  2. getline() don't want to work anymore...
    By mikahell in forum C++ Programming
    Replies: 7
    Last Post: 07-31-2006, 10:50 AM
  3. Why don't the tutorials on this site work on my computer?
    By jsrig88 in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2006, 10:39 PM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. DLL __cdecl doesnt seem to work?
    By Xei in forum C++ Programming
    Replies: 6
    Last Post: 08-21-2002, 04:36 PM

Tags for this Thread