Results 1 to 15 of 15

Thread: cstdio QT C++

  1. #1
    Join Date
    Mar 2010
    Posts
    92
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default cstdio QT C++

    Qt Code:
    1. #ifndef READWRITEFILE_H
    2. #define READWRITEFILE_H
    3.  
    4. #include <string>
    5. #include <iostream>
    6. #include <fstream>
    7. #include <assert.h>
    8. #include <vector>
    9. //#include <stdlib.h>
    10.  
    11. #include "../Misc.h"
    12.  
    13. using namespace std;
    14.  
    15. /*!
    16. This class can be written to a file or read from a file.
    17. */
    18. class InfoReadWrite
    19. {
    20. public:
    21. InfoReadWrite();
    22.  
    23. //!Read the class from a file
    24. void Read(string filename);
    25.  
    26. //!Write the class to a file
    27. void Write(string filename);
    28.  
    29. //!Returns the expected data
    30. vector<float> getData();
    31.  
    32. //!Saves the members to a file
    33. void setData(vector<float> in);
    34.  
    35. //!Returns the timestamp of the file read.
    36. string get_timestamp();
    37.  
    38. private:
    39.  
    40. //!Loads the whole file in a string
    41. string load_txt(string filename_in);
    42.  
    43. //!Save a string in a file
    44. void save_txt(string filename_out, string out);
    45.  
    46. /*!
    47.   mess_in = a message
    48.   left = the left separator
    49.   left = the right separator
    50.   ...will give the last occurence of the match
    51.   */
    52. string find_subs_between(string mess_in, string left, string right);
    53.  
    54. //Data that is read/written
    55. float DeviceNo;
    56. float DownloadB;
    57. float UploadB;
    58. string Timestamp;
    59. };
    60.  
    61. #endif
    To copy to clipboard, switch view to plain text mode 



    i:\programfiles\qtcreator4_62\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cstdio:165: error: '::snprintf' has not been declared
    i:\programfiles\qtcreator4_62\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cstdio:168: error: '::vsnprintf' has not been declared
    i:\programfiles\qtcreator4_62\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cstdio:176: error: '__gnu_cxx::snprintf' has not been declared
    i:\programfiles\qtcreator4_62\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cstdio:179: error: '__gnu_cxx::vsnprintf' has not been declared
    why error ?

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cstdio QT C++

    Why are you using C i/o function in a C++ project?

    snprintf is part of stdio.h

  3. #3
    Join Date
    Jan 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cstdio QT C++

    After speding most of my day trying to figure this out i found that changing "#include <fstream>" to #"include <stdio.h>" fixed it.. in case somebody else has this problem.

  4. #4
    Join Date
    Apr 2012
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cstdio QT C++

    I have the same error like you and when changing the #include the problem is not solved and have this errors that appear:

    ..\Projet\mythread.cpp:80: error: aggregate 'std::ifstream file' has incomplete type and cannot be defined

    ..\Projet\mythread.cpp:82: error: incomplete type 'std::ifstream' used in nested name specifier

    Please how can i solve this? Thanks

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: cstdio QT C++

    These are not the same:

    i:\programfiles\qtcreator4_62\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cstdio:165: error: '::snprintf' has not been declared
    i:\programfiles\qtcreator4_62\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cstdio:168: error: '::vsnprintf' has not been declared
    i:\programfiles\qtcreator4_62\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cstdio:176: error: '__gnu_cxx::snprintf' has not been declared
    i:\programfiles\qtcreator4_62\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cstdio:179: error: '__gnu_cxx::vsnprintf' has not been declared
    ..\Projet\mythread.cpp:80: error: aggregate 'std::ifstream file' has incomplete type and cannot be defined
    ..\Projet\mythread.cpp:82: error: incomplete type 'std::ifstream' used in nested name specifier
    The solution to your problem is to #include <ifstream>.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Apr 2012
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cstdio QT C++

    I started with including #include <ifstream>
    But I have these errors:

    Qt Code:
    1. c:\qt\2010.05\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cstdio:165: error: '::snprintf' has not been declared
    2.  
    3. c:\qt\2010.05\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cstdio:168: error: '::vsnprintf' has not been declared
    4.  
    5. c:\qt\2010.05\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cstdio:176: error: '__gnu_cxx::snprintf' has not been declared
    6.  
    7. c:\qt\2010.05\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cstdio:179: error: '__gnu_cxx::vsnprintf' has not been declared
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: cstdio QT C++

    Great. Now include stdio.h as well.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Apr 2012
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cstdio QT C++

    I have included this after reading this post
    After speding most of my day trying to figure this out i found that changing "#include <fstream>" to #"include <stdio.h>" fixed it.. in case somebody else has this problem.
    but have the followinf errors:
    ..\Projet\mythread.cpp:80: error: aggregate 'std::ifstream file' has incomplete type and cannot be defined

    ..\Projet\mythread.cpp:82: error: incomplete type 'std::ifstream' used in nested name specifier

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: cstdio QT C++

    So you have both stdio.h and ifstream included and you get that error?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Apr 2012
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cstdio QT C++

    I have resolved this but using QTextStream
    Thanks!!!

  11. #11
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: cstdio QT C++

    I have resolved this but using QTextStream
    In other words, you really have no clue what you were doing wrong, despite everyone here telling you exactly what was needed. You'll become a much better programmer if you start trying to understand problems instead of trying things at random until something finally works.

  12. #12
    Join Date
    Apr 2012
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cstdio QT C++

    You are right understanding errors is important but I'm pressed by time, I have a project that should be delivered in May, that's why i have no more time to spend on this

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: cstdio QT C++

    And because of this time pressure you spent 5 days on a problem that could have been solved in 5 seconds. That would leave you with 119 hours, 59 minutes and 55 seconds of time to spend on learning to solve problems such as this one.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. #14
    Join Date
    Apr 2012
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cstdio QT C++

    I'm sorry to tell you that the mathematic operation that you have done is wrong
    posted on 20th April 15:49 and the problem is resolved at 17:52 for the same day
    thus i spended 2 hours 3 min to solve the problem

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: cstdio QT C++

    That's still 2 hours and 3 minutes too much. And you didn't solve the problem. You worked around it. The difference between a solution and a workaround is that in the latter situation the issue is likely to arise again.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.