Doubt: File I/O and DLLs

This is a discussion on Doubt: File I/O and DLLs within the C Programming forums, part of the General Programming Boards category; Hello everybody! I'm a newbie on programming and I'm trying to create a routine to write some calculated variables on ...

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    8

    Question Doubt: File I/O and DLLs

    Hello everybody!

    I'm a newbie on programming and I'm trying to create a routine to write some calculated variables on a text file. There is a lot of file I/O examples on the internet, and I've made some by myself (they work fine), but when I try to use them on a DLL, nothing happens, though the compilation runs successfully.

    Is there any mystery about File I/O and DLLs on C?

    Thanks in advance,

    Gabriel Casagrande

  2. #2
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    684
    I don't get this question.
    Post code...
    ...and, C or C++?

  3. #3
    Registered User
    Join Date
    Sep 2010
    Posts
    8
    I'm using this language to edit an open-source software, which has a graphical interface that uses an engine (a DLL made in C). This software is for hydraulic systems project. On my final thesis, I have to change the original water demand calculations of this model.

    So, I am trying to create a routine to write the variables on a text file and then, pass by pass, know if what I am calculating is correct or not.

    When I use the codes I created in a different project (a console application), everything runs fine: the text file is created, and the variables are written on the file. But, using the same code on the DLL, nothing happens.

    The code is:

    Code:
    void demands()
    
    {
        FILE *f;
        int i;
        f = fopen("demands.txt", "w");
        for (i=1; i<=Njuncs; i++)
       {
           fprintf(f, "%d %d/n", i, D[i]);
       }
       fclose(f);
    
    }
    Where D[i] is the demands array, calculated in other function. I've tried to run the code inside that function, but nothing happened either.

    Thanks,

    Gabriel

  4. #4
    a guy with long hair Xupicor's Avatar
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    103
    Are D and Njuncs global variables? Are you sure Njuncs has the value you think it has? It looks like you're using C and not C++, so this topic should be moved to appropriate section of the forum. Or, are you using C++?

    Also, newline char is '\n' and not "/n".

  5. #5
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    684
    What does 'nothing happens' mean? Ensure your function is called properly. And check if the file is even created.

  6. #6
    Registered User
    Join Date
    Sep 2010
    Posts
    8
    Quote Originally Posted by Xupicor View Post
    Are D and Njuncs global variables? Are you sure Njuncs has the value you think it has? It looks like you're using C and not C++, so this topic should be moved to appropriate section of the forum. Or, are you using C++?

    Also, newline char is '\n' and not "/n".
    Ops! Sorry, It's true, the topic is in the wrong section... I'm using C
    How could I move it to the right section?

    D[i] and Njuncs are global and I've tried to use this code inside the D[i] calculation routine. I guess everything's alright with Njuncs, but I'll look at this carefully.

  7. #7
    Registered User
    Join Date
    Sep 2010
    Posts
    8
    Quote Originally Posted by kmdv View Post
    What does 'nothing happens' mean? Ensure your function is called properly. And check if the file is even created.
    I mean that the file is not created =)

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,635
    Quote Originally Posted by gabrielksa
    Ops! Sorry, It's true, the topic is in the wrong section... I'm using C
    How could I move it to the right section?
    Moved to C programming forum.
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 06-08-2009, 05:33 PM
  2. standart dlls
    By keeper in forum C++ Programming
    Replies: 3
    Last Post: 07-05-2006, 07:32 PM
  3. DLLs <- sound files, and nesting.
    By sean in forum C++ Programming
    Replies: 2
    Last Post: 10-28-2002, 04:13 PM
  4. Compile with *.lib
    By Kelvin in forum C++ Programming
    Replies: 1
    Last Post: 07-23-2002, 06:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21