Thread: need help with a program

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    116

    need help with a program

    Hi everyone. A bit stuck on a program. Im trying to make the basic structure of a prgram but it doesnt seem to work. Can anyone check it and tell me what im doing wrong? Once its working I intend to start putting some meat onto the program but first want the basic shell working:


    Code:
    #include<stdio.h>
    void 1();
    void 2();
    void main()
    {
    char 3;
    char repeat;
    do
    {
    printf("Please press 'b' if you have a something and you wish to do\n or\n please press 'v' if you have something else you wish to do ");
    scanf("%c",&3);
    if (3='b')
    {
    2();
    }
    else
    {
    if (3='v')
    {
    1();
    }
    printf("Do you wish to repeat the program? (y/n)");
    scanf("%c",&repeat);
    }
    while(repeat=='y');
    }
     
     
     
     
     
    void 1()
    {
    
    printf("it works");
    }
     
     
     
     
    void 2()
    {
    
    printf("it works");
    }
    
    due to time constraints Im not looking to increase the functionality of the code, I just want it to work. If we ca get it to print "it works" when I choose that function then that'd be great. i know there are issues with this program but dont have time to make it better, just need a basic functioning program. thanks for your help

    also, as its an assignment ive had to change the details, so that I can see the principles and techniques without risking getting done for plagurism or something.

    I edited important names and replaced them with 1, 2 or 3 so please bare in minf they arent actually 1, 2 and 3 in my program they are sensibly named variables and functions
    Last edited by David_Baratheon; 02-01-2012 at 04:26 PM.

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    your entire post is littered with textbook "we won't help you with that" sentences, its a sorry mess and you should consider a different course if you really cant be arsed to work.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    Registered User
    Join Date
    Jan 2007
    Location
    Euless, TX
    Posts
    144
    your "naming convention" for functions needs some help. Try naming your functions starting with a letter, like "my_1()". I doubt if this program even compiles, much less execute.

    And I agree with the first poster --- try reading a book on 'C' first
    Last edited by kcpilot; 02-01-2012 at 04:20 PM. Reason: add more

  4. #4
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    Quote Originally Posted by rogster001 View Post
    your entire post is littered with textbook "we won't help you with that" sentences, its a sorry mess and you should consider a different course if you really cant be arsed to work.
    I dont understand what you mean by that. Ive seen many others post up some code here and get some help with their errors, is there a problem with mypost?

    what do you mean by textbook "we wont help you with that sentences"?
    Last edited by David_Baratheon; 02-01-2012 at 04:24 PM.

  5. #5
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    Quote Originally Posted by kcpilot View Post
    your "naming convention" for functions needs some help. Try naming your functions starting with a letter, like "my_1()". I doubt if this program even compiles, much less execute.

    And I agree with the first poster --- try reading a book on 'C' first
    I have other names in the actual program but I risk plagurism if I post it exactly the same so deleted them and rpelaced them with numbers. I jave sensible naming conventions in my actual programs. I just need to know in principle wh this program wouldnt work if the naming conventions were correct. Im at university studying electrical and electronic engineering, we have studied some basic c, hello world, variables, loops, if statements and functions and now we have to use them for a simple program but mine isnt working so just needed to get some help with it if thats ok

  6. #6
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    ok maybe i was a bit harsh, it just looks as if you are writing 'oh dear i ran out of time and now i just want something, anything that works, and i dont care what it is'! One error you have is you should use == for comparison, not ' = ' also get some good habits and indent your code properly, and dont worry about renaming fucntions with daft things like 1 ,2 ,3, we are not the KGB, you should use your original code, with the, as you suggest, sensible proper naming conventions, then you wont get people erroneously giving you grief as above. :->
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  7. #7
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    Quote Originally Posted by David_Baratheon View Post
    I dont understand what you mean by that. Ive seen many others post up some code here and get some help with their errors, is there a problem with mypost?
    Yeah, it's annoyingly difficult to read your post because it's strife with error.

    I'm not talking about your code, but at first glance, I see a bunch of obvious errors with that too. (just look at the "if" statements).

  8. #8
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    no problems, thanks for your response. regarding the naming conventions, as I understand it, the university has a plagurism system which searches online so if my exact program comes up it could look bad. I appreciate noone on the site would compromise my studies but just in case the university misunderstands and think i pulled it from the net or something id rather keep the code generic and get general pointers to my errors like the good advice you've already given.

    Definitely we are in agreement on the need for good indentation etc i my actual program. Concerning the ==, which bits need one that ive neglected?

  9. #9
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    Quote Originally Posted by memcpy View Post
    Yeah, it's annoyingly difficult to read your post because it's strife with error.

    I'm not talking about your code, but at first glance, I see a bunch of obvious errors with that too. (just look at the "if" statements).

    i appreciate that, I did try and tidy it up so hopefully there arent too many errors in there now. Thanks

    could you specify exactly what is wrong with the if statements if thats ok?

  10. #10
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    Why will you get done for plagarism? Its your own work after all?? And if the tutor had supplied names like GetFooBar() in the question, then why would there be any harm in using that? The only possible plagarism is in the implementation, the name is entirely subjective.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  11. #11
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    you write
    if suchAndSuch = x
    it should be
    if suchAndSuch == x
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  12. #12
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    please note tht while i think conventions and better practice are important, at this stage im only looking at the things that will stop it working altogether. If if will still work but isnt good practice then it is something I plan to improve in the long run but nee to prioritise things that will completely stop the program working such as one = instead of == or something like this

  13. #13
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    Quote Originally Posted by rogster001 View Post
    Why will you get done for plagarism? Its your own work after all?? And if the tutor had supplied names like GetFooBar() in the question, then why would there be any harm in using that? The only possible plagarism is in the implementation, the name is entirely subjective.


    its not that im committing plagurism its that i might get suspected of plagurism if my exact code is found online. Just saving myself a potential headache by playing it a bit safe. please be understanding of this, it would ruin my life if I got kicked out of uni for plagurism and know people who got kicked out for it, so i just feel more comportable to do it this way just in case

  14. #14
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    please note tht while i think conventions and better practice are important, at this stage im only looking at the things that will stop it working altogether. If if will still work but isnt good practice then it is something I plan to improve in the long run but nee to prioritise things that will completely stop the program working such as one = instead of == or something like this
    Mate your thinking is all wrong, if you keep on with that 'mend and make do' attitude then you will only ever produce ugly, cobbled together hacked workaround programming
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  15. #15
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    Quote Originally Posted by rogster001 View Post
    you write
    if suchAndSuch = x
    it should be
    if suchAndSuch == x

    ok great thanks, thats cut a couple of errors out. Still getting some though, can u see any other obvious errors?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 11-03-2010, 12:45 PM
  2. Help converting array program to link list program
    By hsmith1976 in forum C++ Programming
    Replies: 0
    Last Post: 02-14-2010, 09:50 PM
  3. Replies: 1
    Last Post: 03-03-2009, 04:47 PM
  4. Replies: 5
    Last Post: 08-16-2007, 11:43 PM
  5. Replies: 18
    Last Post: 11-13-2006, 01:11 PM