Thread: need help with a program

  1. #16
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    Quote Originally Posted by rogster001 View Post
    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

    i agree with you 100% but the assignment needs to be in tomorrow and if its not working at all I get zero but if its terirbly written but still does the job ill pass and its quite a large program so for this time i just need to get it going but i do hope to e an active member here and get good habbits in programming in the long run. Ive found this site to be a great resource for c

  2. #17
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    Quote Originally Posted by David_Baratheon View Post
    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
    Ok but you are being a bit paranoid there mate, in all the time i have read these pages i have never seen anybody get any hassle for posting code related to assignments, It is easy as pie to just change your code and presnet abstracts for the purposes of getting help, which is what ideally people do anyway as the work may be big projects and so a sensible small portion of code to illustrate the problem is the best and really only avenue available. In fact its possible people will actually supply a small test portion of code that has been written just to describe an issue, and is not from the work itself, because otherwise there would be too much stuff for members to trawl through. i have posted work related things that cannot be shown complete because of data privacy, but no problem its just a case of 'desensitising' the code or test data ... ie a bit of effort... ;->
    Last edited by rogster001; 02-01-2012 at 04:48 PM.
    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. #18
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    ok will take what you've said onboard but as long as you cant tell from my posts what the project is about then there is no way i could be accused of discussing the assignment with anyone, as it stands this is just a general piece of code with no specific purpose if that makes sense I do know people who got done so am just being safe.

    anyways, the main things id like your guys advice on is my use of functions, if statements, and do while loops. Have I done them wrong as I anticipate the program to work if i fix any little glitches on those areas

  4. #19
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    i agree with you 100% but the assignment needs to be in tomorrow and if its not working at all I get zero but if its terirbly written but still does the job ill pass and its quite a large program so for this time i just need to get it going
    Time to get busy then:- Get the brew on! a good start is fixing the conditional statements as i pointed out earleir ' == ' not ' = ' in comparisons
    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'"

  5. #20
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    Quote Originally Posted by rogster001 View Post
    Time to get busy then:- Get the brew on! a good start is fixing the conditional statements as i pointed out earleir ' == ' not ' = ' in comparisons
    haha true say. I got the statements fixed, that decreased the errors. Can u see any problems with my functions, if statements or do while statements?

  6. #21
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    Well you should be using

    INT!!!!!!! main()

    int main()

    not :
    void main()
    godssake why do tutors keep peddling this ???

    what other errors are you getting exactly .. at compile time? I know you are posting 'psuedo code' but you understand that a variable name cannot be a number right? you can have

    Code:
    int var1 = 1
    but you cant have

    Code:
    int 1 = 1
    And I know you have chosen a ' do... while ' loop but initiallise your char to something first. Dont just sail off into the loop and count on the user supplying a meaningful value for you.
    Always init your vars.
    Last edited by rogster001; 02-01-2012 at 05:09 PM.
    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. #22
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    regarding the int main issue, my book says int main and my teacher says void main. Am I right in thinking this is more an issue of best practice as opposed to something that would totally stop the code from working?

    I havent got variables as numbers, in my code its definitely a valid name so thats that ruled out.

    regarding the do while loop, shall I declare it with a value?

    Im getting this error twice:

    1>f:\mywork\visual studio 2010\projects\worksheets\worksheets\source files\assignments\simplified version\assignment 1 - shell of program.c(14): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(304) : see declaration of 'scanf'


    But I think thats not an error to worry about as I always get it and the program usually still works. Any idea what it means?

    The other error is:


    1>f:\mywork\visual studio 2010\projects\worksheets\worksheets\source files\assignments\simplified version\assignment 1 - shell of program.c(39): error C2059: syntax error : 'type'
    1>
    1>Build FAILED.
    1>
    1>Time Elapsed 00:00:01.24
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



  8. #23
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    yes i know u know about the names, i was just checking you hadnt also done that in your ' real ' code.

    you first one is a warning, deprecated means that you are using an outdated method or that the method has a newer version or more up to date anything that should be used in preference to the one you are currently invoking. It is simply a standards conforming message, and should be taken notice of, otherwise you could quickly find yourself relying on things that while they may build and work for you cannot be guaranteed to work beyond your own machine.

    the actual error looks like a major typo thing, like a missing ; or summat, but i dont use visual c++ so not familiar with the context there, i wil have another look at your ' code '
    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'"

  9. #24
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    You need to show the actual line the error is referring to
    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'"

  10. #25
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    regarding the int main issue, my book says int main and my teacher says void main. Am I right in thinking this is more an issue of best practice as opposed to something that would totally stop the code from working?
    No its not just'best practice' although i see where you may be coming from. It is there for a reason, these things are hammered out over like eleventeen years amongst a band of heavyweight boffins and general contributions thus the standards are defined. The grey areas are hopefully eliminiated by this process..in an ideal world anyway.. so returning an int value to the operating system at program close is now defined as the standard. There are others much more qualified to expand on that subject for you than i am, and there are links in recent posts that you could go to with fuller explanations.
    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. #26
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Here is the errors I get compiling your pretend code;
    I am going to pretend it helps you.

    Do you now see why posting pretend code does NOT help you?

    Tim S.

    Code:
    Compiling: main.c
    H:\SourceCode\Projects\testidiot\main.c:2:6: error: expected identifier or '(' before numeric constant
    H:\SourceCode\Projects\testidiot\main.c:3:6: error: expected identifier or '(' before numeric constant
    H:\SourceCode\Projects\testidiot\main.c:4:6: warning: return type of 'main' is not 'int' [-Wmain]
    H:\SourceCode\Projects\testidiot\main.c: In function 'main':
    H:\SourceCode\Projects\testidiot\main.c:6:6: error: expected identifier or '(' before numeric constant
    H:\SourceCode\Projects\testidiot\main.c:11:12: error: lvalue required as unary '&' operand
    H:\SourceCode\Projects\testidiot\main.c:12:6: error: lvalue required as left operand of assignment
    Process terminated with status 1 (0 minutes, 0 seconds)
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  12. #27
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    ok, I have made some improvements on the code based on the initial feedback i was given,I have a class in 5 mins but after, I will post my updated code and choose more sensible names for the variables as I appreciate you guys are helping me and shoudlnt have to go through the hassle of changing the variables before running it in the compliler as its me who is looking for help. Ill post up an updated version later. Thanks for your help everyone

  13. #28
    Lurker
    Join Date
    Dec 2004
    Posts
    296
    Quote Originally Posted by David_Baratheon View Post
    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
    If your school has even a half decent system to detect things like this then it will not matter what you name your variables. Such a system will not look at variable names, in fact, the first thing you do is rename all variables in the program systematically and then you compare the structure of the program.

    So the only thing you achieve by having bad variable names is that anybody that reads your post goes "I won't spend any time reading that, he doesn't even have decent variable names. I'll help somebody else instead.".

  14. #29
    Registered User
    Join Date
    Jul 2011
    Location
    Champaign, Illinois, United States
    Posts
    27
    Quote Originally Posted by David_Baratheon View Post
    regarding the int main issue, my book says int main and my teacher says void main. Am I right in thinking this is more an issue of best practice as opposed to something that would totally stop the code from working?

    I havent got variables as numbers, in my code its definitely a valid name so thats that ruled out.

    regarding the do while loop, shall I declare it with a value?

    Im getting this error twice:

    1>f:\mywork\visual studio 2010\projects\worksheets\worksheets\source files\assignments\simplified version\assignment 1 - shell of program.c(14): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(304) : see declaration of 'scanf'


    But I think thats not an error to worry about as I always get it and the program usually still works. Any idea what it means?

    The other error is:


    1>f:\mywork\visual studio 2010\projects\worksheets\worksheets\source files\assignments\simplified version\assignment 1 - shell of program.c(39): error C2059: syntax error : 'type'
    1>
    1>Build FAILED.
    1>
    1>Time Elapsed 00:00:01.24
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



    the scanf warning just means that scanf is an unsafe function (meaning that someone could exploit it using buffer overflow or something like that). In your case it probably wont matter which one you use. For the actual error I don't know what line 39 is. You should post that...

  15. #30
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    Quote Originally Posted by breimer273 View Post
    the scanf warning just means that scanf is an unsafe function (meaning that someone could exploit it using buffer overflow or something like that). In your case it probably wont matter which one you use. For the actual error I don't know what line 39 is. You should post that...
    thanks for your incredibly useful post. Interesting info concerning the scanf warning. I agree it will probabily not affect me but is something to remember in future when my skills improve if Im working on something that could be affected.

    Ill post line 39 now:

    Code:
     void function2()
    {
    //Input colours and output value
    printf("print something");
    }
    
    


    instead of using a number i put in function2 as the name of the function but its basically a variable being called up in the main program.

    Ill post up the full code with minor alterations:

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