Click here to Skip to main content
15,896,278 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
help pliss,,
i have a problem,,
I'm in charge of making a project struct with pointer;
like this,,
struct whatever{
int next;
int previous;
int value = 5;
};
so if the user input:
1 1
display 5,
if user input :
2 1 3,
2 3 7,
value = 3,5,7
if user input :
3 2;
value = 3,7;
5 is erase..

but this program just use pointer and struct, help pls

What I have tried:

i try to creat this program 2 day but no result:(
Posted
Updated 10-Jul-18 19:52pm

this link[^] is going to help you.
 
Share this answer
 
Those aren't pointers.
For a struct that you can use as a node, try this:
#include <stdio.h>
#include <stdlib.h>

struct whatever{
struct whatever *next;
struct whatever *previous;
int value;
};
int main()
{
    struct whatever * node1 = (struct whatever*)malloc(sizeof(struct whatever));
    node1->value = 100;
    struct whatever * node2 = (struct whatever*)malloc(sizeof(struct whatever));
    node2->value = 200;
    node1->next = node2;
    node2->previous = node1;
...
    //release the memory
    free(node1);
    free(node2);

    return 0;
}
 
Share this answer
 
v2
Comments
Member 13906640 11-Jul-18 2:59am    
please can you write the script all of it? I've tried it 2 days but it did not work
OriginalGriff 11-Jul-18 3:15am    
No. We do not do your homework!
Member 13906640 11-Jul-18 3:03am    
not using node, I just told to use pointer and struct
OriginalGriff 11-Jul-18 3:15am    
"node" is just a name for an individual item in a linked list ...
Member 13906640 11-Jul-18 3:22am    
so how do i add element to int value from struct?
i try
struct test {
int value
};
test * ptr, testt;
ptr = & testt;
int enter;
while (true)
{
cout << "enter:;
cin << (* ptr) .values;
}
so when user input 5 and 6 ,,
testt.value == 6; and the 5 lost;
how to calculate testt.value == 5, 6?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900