Search:

Type: Posts; User: edishuman

Search: Search took 0.01 seconds.

  1. initializing a vector of structs in class constructor

    How would I initialize certain fields in a struct in a class constructor?
    I want to create a 11x11 vector.

    Say I have the struct:


    struct tree_node
    {
    int x, y;
    int visited;
  2. Thread: Trees in C++

    by edishuman
    Replies
    3
    Views
    2,571

    Trees in C++

    Hello all I'm trying to implement a tree in C++ with multiple children. There are compilers errors I'm trying to understand, but most likely it's implementation. I've looked at source codes for trees...
  3. Replies
    1
    Views
    1,025

    Grabbing input text file using a stream

    I wrote some code to grab input from a text file. I know specifically the format of the text file and the program was made tailored to only that specific format. I know this is pretty bad practice...
  4. Replies
    5
    Views
    1,334

    I'm curious as to why the function needs to be...

    I'm curious as to why the function needs to be static / non-member. I'm looking at the c++ reference page and the comparison function seems to work fine.

    Also curious as to why we need it to be...
  5. Replies
    5
    Views
    1,334

    Sorting a vector of objects

    I'm implementing kruskal's algorithm and ran into some troubles compiling. I need to sort a vector of objects by value. Here is my code and the error I'm getting.



    //These are the two functions...
  6. Organizing and optimizing code into source and header files

    I'm a new C++ programmer coming from java. I translated Dijkstra's algorithm from java into C++. I know this is not good programming practice, hence I will post the code here for optimisation...
  7. Initializing and declaring arrays in classes

    Hey, I'm picking up C++ by translating java code to C++. Currently I'm working on translating dijkstra's algorithm. I have the completed code in java and it works perfectly. I need some help with the...
  8. Grabbing stats on a file using unix command

    This is almost half my program. I'm currently working on it in small parts. The immediate problem is about grabbing file info using lstat and converting the time modified to local time.

    ...
  9. Replies
    1
    Views
    4,324

    generic insertion sort

    So I have an insertion sort here that is supposed to take in any type of input. I have the insertion algorithm correctly. The problem is with the swapping of the pointers. I don't really see what I'm...
  10. Replies
    1
    Views
    701

    Using getopt(3c) correctly

    Hello all, I'm having trouble with getopt(3c) scanning in characters from command line. Specifically I want to see if two occurrences of the same character are present within the argument.

    So for...
  11. Replies
    1
    Views
    2,212

    Valgrind error help

    Hello all, I have a simple program that takes in user inputs into a queue and spits them back out if EOF is encountered. My problem lies in the errors I'm having when running valgrind. I'm afraid I...
  12. Replies
    3
    Views
    1,481

    Ah thank you guys, this was what I was missing.

    Ah thank you guys, this was what I was missing.
  13. Replies
    3
    Views
    1,481

    Pointer pointing incorrectly

    What this program is supposed to do is take in user input and print them in lexicographic order using a linked linked. Say I typed in the words foo, bar, qux; the program should print out bar, foo,...
  14. Replies
    4
    Views
    1,610

    Well what I want it to do is have list be null so...

    Well what I want it to do is have list be null so that


    node_ref curr = list->head;

    would be null. If curr is null, then the while loop just below it doesn't run.
  15. Replies
    4
    Views
    1,610

    C Segfault help

    //
    // Declaration for linked list of nodes.
    //
    typedef char *cstring;
    typedef struct node *node_ref;
    struct node {
    cstring string;
    node_ref link;
    };
  16. Replies
    2
    Views
    878

    Character Array Help

    Hello all, I've encountered something that obviously should not happen in C. I declared an array of characters of say length 10 and insert 12 characters into it and it works fine. Why does this...
  17. Replies
    10
    Views
    3,063

    Well what I was told was to use character...

    Well what I was told was to use character scanning and scan strings one by one. It has definitely helped me realize what happens in the process of reading strings. I have learned of the scanf()...
  18. Replies
    10
    Views
    3,063

    Simple check/deposit exercise in C

    I'm teaching myself C atm, reading online tutorials and doing exercises at the end of the chapters. What I've written is a program that reads in either check/deposit and adjusts the amount in the...
Results 1 to 18 of 18