Hahah ok that's what I thought :)
Thanks then! everything is working as expected thank you very much for the help!
Type: Posts; User: beta3designs
Hahah ok that's what I thought :)
Thanks then! everything is working as expected thank you very much for the help!
Ok got the delete_column function coded now but I just have one doubt, here it is:
/* delete_column: delete column n from table t */
void delete_column(table *t, int n){
int i, j;
...
Okeeey then now I understand it thanks a lot! I will try to get the delete_column to work now and I will come soon if I have problems, but I think the idea is pretty similar.. Thanks again!
Ok I understand that isn't actually wrong and now I think I understand the idea but when you said "data" did you mean all the table entries without the deleted row?
Well I coded this:
void...
Ok, but I was just trying to follow quzah's example:
I know I have two pointers pointing at the same place but as I was following quzah's example I thought I needed to free the old row pointers...
Mmmmm nice...Why disaster may I ask? then I don't know what else to do thanks for the help!
Ok so I think I got now in my head what you are saying, I should free data in my code not t->cell, I use data to modify the table then free data right? Well I will try to code it that way, seems...
Yeah I know that but do you mean doing t->cell = data just before freeing t->cell or how can I delete the "old" t->cell? I can't still get how can I redefine let's say "A" and then delete old "A"? I...
Yeah I that's what I meant a few posts ago that I don't want to create a new table I need to modify this one, thus freeing the table seemed to me a bit weird
How should I go about that then? I...
Yeah thanks I noticed, I'm just getting so confused on getting this to worked so I'm messing things lol
What I've got so far is:
void delete_row(table *t, int n){
int i;
--(t->rows);...
@grumpy I think those digits followed by the semi-colon are for us to find the lines aren't they?
Anyway he is missing some brackets after the if statement it should be:
if (isdigit(p[k]))
and...
Sorry but I was a bit busy this week so I couldn't get to code this but here I am again, this is what I wrote with the algorithm quzah told me again:
/* delete_row: delete row n from table t */...
But I need to modify the table t, the function doesn't return anything it's a void and if I create new pointers I shall return them so I can work with them later shouldnt I? the function I'm coding...
Ok, the problem with your solution quzah is that I should delete the olddata which I don't want to do I want to modify the original table (or data)... I coded this and it seems to work, it is what...
Ok thanks very explanatory ^^
I'll try to code it and see if I get it right and I'll come back with the result :)
Thanks again ^^
Sorry I got a bit lost then you mean I should free the row I want to delete, reasign pointers and then reallocate the memory?
Ok ;D
Thanks in advance and sorry to ask the "same" question again but...
Oh nice, so Instead of reallocating the memory I need to free it? Or is it the same? I mean let's say I reassign my row pointers which is moreless what I had thought of when I said shifting the...
Ok as part of my project described here I was trying to delete a complete row and column of a 3d dynamic array some kind of 2d matrix of strings...
Well I'll try to ask the simple question for 1d...
Aaah yeah I understand what you mean :P
Good, my program now works as expected so unless someone wants to say something, topic solved.
Ok thank you very much, updated code is now:
void add_row(table *t){
int i;
// Increase rows count
++(t->rows);
t->cell = (char ***) realloc(t->cell, t->rows *...
Ok having problems now adding rows instead of column... seems I can't learn from my mistakes... u.u
Now I'm trying to add a new row but I'm getting the same kind of error, here is what I have so...
Yeah sorry I just changed that before you posted! lol
And now it works as expected sooo problem solved and thank you very much!! I will have to change the gets and the fflush thing now...
P.S....
Ok my new code is this:
void add_column(table *t){
int i;
// Increase columns count
++(t->cols);
for(i = 0; i < t->rows; ++i){
Thanks for the tip on fflush(stdin) didn't know about that...
The project I'm writing is some kind of database and since it's very simple it doesn't ask the user which kind of input he wants to...
Sorry it was meant to be how it is now:
t->rows * sizeof(char *) and not
t->cols * sizeof(char *)... I don't know why I changed that neither lol...
But that's what this does doesn't it?:
...