Thread: Code Comments(Return Types)? & Dev-C++ New Version Error?

  1. #1
    #junkie
    Join Date
    Oct 2004
    Posts
    240

    Code Comments(Return Types)? & Dev-C++ New Version Error?

    Code:
    1 C:\path\index.cpp [Warning] `nul.gcda' is not a gcov data file
    Anyidea what that means? I get it whenever i use the syntax check on Dev C++ 4.9.9.2. But not when i compile..


    Also, I'v got a question about the following code.
    Code:
    class cItemHandle
    {
        public:
            cItemHandle();
            ~cItemHandle();
            float returnValue(string itemName);
            bool  setValue(string itemName);
        private:
            string fileData;
    };
    cItemHandle::cItemHandle()
    {
        ifstream iFile("stats.dat", ios::ate);
        int size = iFile.tellg();
        iFile.seekg(0, ios::beg);
        char* ch = new char[size];
        iFile.read(ch, size);
        fileData = ch;
        iFile.close();
    }
    cItemHandle::~cItemHandle(){}
    float cItemHandle::returnValue(string itemName)
    {
        int stringStart =       fileData.find(itemName,0);
        int stringLineEnd =     fileData.find("\n",stringStart);
        int valueStart =        stringStart + itemName.length() + 1;
        int valueLen =          stringLineEnd - valueStart;
        
        cout<<"\nName: "<<itemName;
        cout<<"\nStarts At: "<<valueStart;
        cout<<"\nEnds At  : "<<stringLineEnd;
        cout<<"\nReturn Value: "<<fileData.substr(valueStart,valueLen);
        return 0.1;
    }
    bool cItemHandle::setValue(string itemName)
    {
        return false;
    }
    If you notice i am taking a files data, storing it in a string (Thanks Lithorien ) and doing various things with it. Well i'v got a question about the return values..
    I could easily deal with the return values all being float's, which is what i first planned on. But i decided i might try to expand on that, though i dont know how to handle such things.
    Seeing as a method must first run through the string to find the value (which is in this format)
    Code:
    item1=value
    item2=value
    item3=value
    how can i deal with the return type? like i said originally i planned on them all being float values but then decided to see if i could change it to any type. I mean if i could just do a simpe if to check what types they are, thats one thing, but then i still cant return any type.

    Down the road when i am pulling data from the string's item values for calculations and whatnot, i should know what everythings data type is (ie height=float, name=string), so that shouldent cause any problems.. i am more concerned about programming for multiple return types.

    So how could i handle multiple return types? Thanks
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

  2. #2
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    A function can return one and only one thing at a time. But often, one wants to return more than one thing from a single function. To do this, use reference parameters:
    Code:
    void foo(int &x, double &y);
    
    int main()
    {
       int x;
       double y;
       cin >> x >> y;
       foo(x,y);
       cout << "x: " << x << endl
               << "y: " << y << endl;
       return 0;
    }
    
    void foo(int &x, double &y)
    {
       ++x;
       y *= 1.5;
    }
    Try that out. As you can see, foo() is void and thus returns nothing, but it is able to change the values of x and y because they were passed by reference, so in a way, it's as if the function is returning an int and a double.

  3. #3
    #junkie
    Join Date
    Oct 2004
    Posts
    240
    how can i see if two data types are the same?
    That and i assume i'll have issues with figuring out what data type the substring is ment to be.
    ie
    Code:
    string.substr(0,4) // this returns 0.05 as a string
    How could i tell which data type that actually is? Or hmm, it "should" be. in this example the string returns a string that should be a "float"
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

  4. #4
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    The <cctype> library has the functions isdigit(), isalpha(), isspace(), etc. that can determine whether a single character is a digit or letter or whitespace, etc.

    There's also the atoi() and atof() functions which take a char* and return an integer and a double, respectively; however, in order to use these, you ought to know what you're working with first.

  5. #5
    #junkie
    Join Date
    Oct 2004
    Posts
    240
    know what i'm working with or what i'm doing lol

    What i'm working with is a string that i wish ti determine what it is, then convert it to what it should be. Ie if its a ASCII characters "1", "0", and "5", i wish to turn it to the Integer 105. Ect..

    (had to edit that, wrote the ascii part like the number 105 was a single ascii character number.
    Last edited by Zeusbwr; 04-05-2005 at 05:08 PM.
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

  6. #6
    #junkie
    Join Date
    Oct 2004
    Posts
    240
    i was googling the commands atoi() and whatnot,

    http://mathbits.com/MathBits/CompSci...nc/Convert.htm
    is a little example,
    One thing, the parameter it takes is a character array correct?

    Also, is this the ASCII value or what? In otherwords i want
    myString = "0.014";
    float = myString;
    cout<<myInt; // returns 0.014
    Last edited by Zeusbwr; 04-05-2005 at 05:16 PM.
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

  7. #7
    Registered User
    Join Date
    Dec 2010
    Posts
    1
    I am facing the same problem....

    "profiling:%s:Not a gcov data file"

    Anybody has any pointers. Please help.

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    1. Please read the forum rules and pay attention to things like "don't bump dead threads". This one was 5 years old.

    2. Did you also search your error messages?
    Of course you did, that's why you're here. It's #1 on the list.
    But did you keep reading through the list?
    At #5 there is FW: nul.gcda warning - msg#00009 - gnu.dev-cpp.user

    3. Dev-c++ is old, buggy and unmaintained.
    Try Code::Blocks
    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. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  2. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  3. using c++ in c code
    By hannibar in forum C Programming
    Replies: 17
    Last Post: 10-28-2005, 09:09 PM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM