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;
Type: Posts; User: edishuman
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;
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...
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...
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...
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...
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...
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...
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.
...
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...
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...
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...
Ah thank you guys, this was what I was missing.
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,...
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.
//
// Declaration for linked list of nodes.
//
typedef char *cstring;
typedef struct node *node_ref;
struct node {
cstring string;
node_ref link;
};
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...
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()...
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...