This is the scenario:
1. user inputs an int N for the desired level
2. if N is greater than the total number of levels in the tree, repeat input
3. if N is less than 0, repeat input
4. if N is...
Type: Posts; User: budala
This is the scenario:
1. user inputs an int N for the desired level
2. if N is greater than the total number of levels in the tree, repeat input
3. if N is less than 0, repeat input
4. if N is...
I'm sorry but I can't build a matrix with a large enough number of rows, because the rows should grow dynamically :(
I start with a matrix which has 10 columns and just one row, and I would like to add a seccond row below that one if the elements in the first row satisfy a certain property, add a third if the...
got it!
I think I didn't make my self clear. When I said "end" i thought "after the last node in the list" or more precisely "before the beginning in the list"
Hi there. Long time no read :)
I have a problem with my circular list. I can add a node to the end of the list just fine, but I can't seem to add it to the beginning.
This is (sort of a...
dang nabbit :D
yes i did read it and thats what led me to believe that instead of remembering to free everything I could use alloca
@Salem - did I then misunderstand the purpose of alloca? Is it not suppose to do the allocating and freeing of memory instead of ... Me? :D
When I input name: "abc", age: "20", id: "1" the printout function returns this to the screen
NAME: ????!?!? AGE: 1832928 ID: 29382235
I would like to dynamically allocate memory for nodes in a linked list. I used to use malloc() and free() afterwards, but heard lately that it's simpler (with certain limitations like running out of...
I would like to avoid hashing. Not that I'm affraid of it, just want to do it the "normal" way using only that one linked list ;)
How would one go about deleting every single person (node) from a singly linked list which has the name Jack?
i.e.
Start:
Jack -> John -> Ann -> Bill -> Jack -> Jack -> Frank -> Jack
...
that's exactly that! I figured out that my logic is flawed in that respect ;)
That's what happens when you replace with copy/paste, and then add some more code whilst forgetting to replace it also :D
Anyways, replaced the idioms in my native language with english ones, and...
Hi there, long time no bother :D
I am trying to sort a singly linked list using pointer manipulation using a "selection sort"-ish algorithm and I'm having problems.
My idea is this:
1....
solved it. trivial really but not a couple of hours ago :D
one simply needs to keep track of the element from which we are using the desired field for comparison. I called it element x :D
int...
I have an array of structs
typedef struct node
{
int a,b,c,d;
} element;
...
element array[5];
I want to sort an array using bubble sort. I know it's the slowest but i have only 5-10 elements so it's fast enough. My algorithm for bubble sort works cause if I code this
void Bubble(int...
since an array of chars is basically a string, why not try this...
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main (int argc, const char * argv[])
Of course, but apart from that, if the user ALWAYS enters less than 20 characters, is it ok?
is anything wrong with this approach?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void str_output(char *x)
{
scanf("%s", x);
I guess I could/should have included a break in the for loop after it finds the sought node :)
I wasn't expecting for all my problems to be solved. The fact that on this forum one doesn't get the code wrapped up in shiny paper is a great plus for me as it is more important to realise why...
Nope, still doesn't work! It doesn't delete the node i want when it does exist, but it does return 0 when i try to delete a non-existing node.
I colored the new lines of code red
int...