Search:

Type: Posts; User: creativeinspira

Page 1 of 2 1 2

Search: Search took 0.00 seconds.

  1. Checking if a file descriptor is valid

    Hey, does anybody know how to check whether the file descriptor is valid?
  2. Replies
    0
    Views
    1,528

    Interactive Programs

    Hey Guys,
    When writing a shell, what is the technique for supporting interactive programs such as pico, more, and less. Suppose that a program has both, a keyboard input as well as a piped one...
  3. Replies
    7
    Views
    1,411

    Simply moving it to a header file works. But if...

    Simply moving it to a header file works. But if you put the function declaration in the .h file and definition in .cpp file that does not work.
  4. Replies
    7
    Views
    1,411

    Before I had a function in a .h file. Once I...

    Before I had a function in a .h file. Once I move it to a cpp file it works fine. I have done it like this:


    template<typename T>
    void func(vector<T>& vec)
    {

    }

    int main()
  5. Replies
    7
    Views
    1,411

    st is the type of somestruct

    st is the type of somestruct
  6. Replies
    7
    Views
    1,411

    Templates

    Hey guys,
    Here is what I am doing:



    template <typename T>
    void func(vector<T> vec)
    {
    ..
    ..
  7. Replies
    5
    Views
    1,548

    Sorting Vector of Structs in STL

    Hey guys. Do any of you know a way to sort a vector of structs in STL? I tried using a comparator such as



    class compare
    {
    bool operator(structtype st1, structtype st2)
    {
    ...
  8. Replies
    1
    Views
    1,069

    Timing In C++

    Hey Folks. Question here. I am writing a program in C++ in linux. I need to time a piece of code. Currently I am using the times function in <sys/times.h>. It gets me the time alright (time...
  9. Replies
    1
    Views
    901

    fstream

    Hi everybody. Does anybody know of a way to insert a line of text in the begging of the textfile without having to read an entire file in a loop? Preferably using ifstream? Thank you for the...
  10. Replies
    9
    Views
    4,816

    Thanks to you for all who tried to help. I can't...

    Thanks to you for all who tried to help. I can't post detailed code. I will just figure this out myself.
  11. Replies
    9
    Views
    4,816

    Nope.

    Nope.
  12. Replies
    9
    Views
    4,816

    Yet even stranger: If I add the following...

    Yet even stranger:

    If I add the following code, the core dump goes away:



    void somClass::addNewInt(const int& newInt)
    {
    vector<int> vec2;
    vec2.push_back(newInt);
  13. Replies
    9
    Views
    4,816

    I realized something else too: if I cout the...

    I realized something else too: if I cout the newInt, it is correct. However, if I try to push it, a core dump happens. Now, here is the kicker: if I replace newInt with some other integer (local ...
  14. Replies
    9
    Views
    4,816

    STL vector core dump

    Hey everybody. I have an issue where pushing a new item onto an STL vector, I get a core dump. Now, the capacity of the vector is not exceeded (its only 3). The vector contains integers. Now, in...
  15. Replies
    3
    Views
    1,418

    Thank you. So I can just do #define NDEBUG in my...

    Thank you. So I can just do #define NDEBUG in my main file, and then all the code between #ifndef and #endif will be deactivated?
  16. Replies
    3
    Views
    1,418

    C++ Debug messages

    Hi everybody. I was wondering if there is a way in C++ to have debug messages, and the ability to turn them off. For example, lets say I would like my program to have two modes. One mode is the...
  17. Replies
    11
    Views
    1,796

    This confirms it, thank you.

    This confirms it, thank you.
  18. Replies
    11
    Views
    1,796

    STL vectors and erase

    Hey everybody. I understand that erasing elements in the vector invalidates the iterators. If you consider the following code:



    #include <iostream>
    #include <vector>
    using namespace std;
    ...
  19. Replies
    10
    Views
    1,734

    Yeah, thanks everybody I fixed it.

    Yeah, thanks everybody I fixed it.
  20. Replies
    10
    Views
    1,734

    I think you are right. My file is 7 bytes...

    I think you are right. My file is 7 bytes somehow. I don't quite understand why, since hello is the only thing in it. I examined it in hex editor, and it appears to confirm it. I attached the...
  21. Replies
    10
    Views
    1,734

    The output is:

    The output is:

    <--hello
  22. Replies
    10
    Views
    1,734

    Here is my code. I am using g++ on ubuntu linux...

    Here is my code. I am using g++ on ubuntu linux btw.



    #include <iostream>
    #include <string>
    #include <fstream>
    using namespace std;

    int main()
  23. Replies
    10
    Views
    1,734

    Strange problems with string class

    Hey Guys. This is a weird one. Basically what I am doing is reading a string from the file using getline(file, buffer) where buffer is a C++ string. For example: lets say the file contains the string...
  24. Replies
    3
    Views
    9,842

    STL set of structs

    Hi Everybody. If any of you know how to make an STL set of classes or structs, that would be cool. Which operators do you need to implements so if I have myclass, I can have an stl set of type...
  25. Replies
    3
    Views
    1,057

    This will get the usage only for the dynamic...

    This will get the usage only for the dynamic memory. However, I want the usage for the whole program. Thanks for trying to help though.
Results 1 to 25 of 34
Page 1 of 2 1 2