Thread: Function and Pointer problem

  1. #1
    Registered User
    Join Date
    Sep 2014
    Posts
    3

    Function and Pointer problem

    So for a project, my professor sent out two pages of code containing functions to read a text file (since we do not know how to write this on our own yet). I've got the code working on Orwell IDE and it gives me 2 warnings saying

    "Passing argument 1 of 'readFromFile' from incompatible pointer type"

    "Passing argument 2 of 'option2Print' makes integer from pointer without a cast"

    The Orwell IDE seems to just bypass these warnings and compiles the code correctly. However, when I transferred my files over to my desktop using BloodShed (what the professor uses), instead of getting a warning I get an error and the code won't compile.

    I assume it will not compile on his computer either since he uses the BloodShed IDE. I would love if anyone can explain any quick fixes for this!

    I don't know how to put the code directly into the text neatly, so a attached a .zip file with my code. The "storms.txt" file is also included. (the file that will be read). Thanks!
    Attached Files Attached Files

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Normally, warnings are advisory: you are free to ignore them, but if you are not absolutely certain why a specific warning can be safely ignored, then you do so at your own peril. Often, compilers may have a setting that allows one to treat warnings as errors, so perhaps that is what is happening. Another possibility is that you're incorrectly compiling your C code as C++, in which case the stricter type rules of C++ could be in effect (or not).

    Quote Originally Posted by austin.18
    I don't know how to put the code directly into the text neatly
    Post your code in [code][/code] bbcode tags.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Sep 2014
    Posts
    3
    Hmmm. Ok. The IDE is set to compile C code, so probably its treating the warnings as errors. I'm going to try and email the professor and see if he gets the same problem when compiling.

    Still open to any other ideas :]

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Instead of worrying about this, just fix the code: figure out what are the required types and why what you provide doesn't match, then figure out how to properly make them match.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Sep 2014
    Posts
    3
    I figured it out! Thanks for the responses!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with pointer to function problem
    By rob90 in forum C Programming
    Replies: 19
    Last Post: 05-28-2010, 10:33 AM
  2. Pointer to function problem
    By vincent01910 in forum C Programming
    Replies: 6
    Last Post: 08-29-2009, 08:14 AM
  3. Problem with function's pointer!
    By Tirania in forum C Programming
    Replies: 5
    Last Post: 11-28-2008, 04:50 AM
  4. Pointer in Function problem
    By lilhawk2892 in forum C++ Programming
    Replies: 7
    Last Post: 12-08-2007, 02:41 AM
  5. Replies: 4
    Last Post: 11-05-2006, 02:57 PM

Tags for this Thread