joel
Vladimir
Oleksandr
in fact, that is not even an allocation... just dummy guard while compilation
joel
Oleksandr
Vladimir
joel
still trying to figure out what is going on
Oleksandr
joel
Oleksandr
Oleksandr
hm...
joel
Oleksandr
oh
don't hate me, this is just for games😂
joel
joel
isee steam
Oleksandr
the four horsemen of the apocalypse
Oleksandr
joel
i need to try these games with wine
Victor D.
𝕵𝖔𝖘𝖚𝖊
/saved
𝕵𝖔𝖘𝖚𝖊
#ot
Shubham
Shubham
I am getting Segmentation Fault I can't identify where.
Can someone see the code and tell me?
梅
梅
梅
梅
Shubham
Yes
In linked list
Head is null later new added new node will go to head
Shubham
I think there is something wrong in Insertnth()
梅
Shubham
Okay I will try it
梅
maybe there are more problems with Insertnth😂😂😂
梅
梅
Shubham
Shubham
I made a pointer pointing to head so that I can traverse the list
Zero
Shubham
Point is pointing to head right?
So it should traverse the list and point->next should store in point..
Any mistake here?
梅
Explain
question 1 memory leak
head addr is 0xabcd....
...
Node *point = new Node();
(if point addr is 0x12345......)
point = head;
(point addr change is 0xabcd)
how release 0x12345...?
...
梅
梅
where is init next point?
Shubham
Monoswee
https://bit.ly/2Jty4mb
梅
Yashpal
https://paste.ubuntu.com/p/3F5KQpQ6yK
梅
Shubham
Thanks!
But I want to write by own to learn
I won't open it until I solve mine 😂
梅
Yashpal
Dima
Dark souls code
Visual souls 3
rakesh
/warn
Crescenzo
Someone who can explain how to compare two consecutive integers (subsequence) in a linked list?
Example:
1, 2, 5, 13, 7, 8, 23
Output (with sum subsequence):
3, 5, 13, 15, 23
Thx!
Crescenzo
Language C.
Crescenzo
If you need it, I have a code designed by me, but I have a block on the consecutive comparison conditional..
Oleksandr
Someone who can explain how to compare two consecutive integers (subsequence) in a linked list?
Example:
1, 2, 5, 13, 7, 8, 23
Output (with sum subsequence):
3, 5, 13, 15, 23
Thx!
Explain sum logic
Oleksandr
Why 1+2 and not 2+5?
Crescenzo
No, 1+2 and 7+8, sum of consecutive numbers (subsequence)..
Oleksandr
Ok, understand know(just don't know meaning of "consecutive")
Oleksandr
Give me your code
klimi
Give me your code too
Crescenzo
Ok sorry Alexander!
Crescenzo
The exercise asks me to eliminate consecutive elements (1,2,7,8) and replace them with their sum (1+2 and 7+8)
klimi
I love this chat
Crescenzo
Crescenzo
struct elem
{
int info;
struct elem *next;
};
struct elem *readFile (FILE *fp, struct elem *top);
void printList (struct elem *top);
struct elem *writeFile (FILE *fp, struct elem *top);
int main()
{
struct elem *top=NULL;
FILE *fp;
fp=fopen("inputFile.txt","r");
top=readFile(fp,top);
fclose(fp);
printList(top);
fp=fopen("outputFile.txt","w");
writeFile(fp,top);
fclose(fp);
}
struct elem *newelem (int info)
{
struct elem *nodo;
nodo=(struct elem *)malloc(sizeof(struct elem));
if (nodo==NULL)
return NULL;
nodo->info=info;
nodo->next=NULL;
return nodo;
}
struct elem *insertList(struct elem *nodo, struct elem *top)
{
if (top==NULL)
return nodo;
top->next=insertLista(nodo, top->next);
return top;
}
struct elem *readFile (FILE *fp, struct elem *top)
{
int info;
struct elem *nodo;
while (fscanf(fp,"%d",&info)>0)
{
nodo=newelem(info);
top=insertLista(nodo,top);
}
return top;
}
void printList (struct elem *top)
{
while (top!=NULL)
{
printf ("%d -> ",top->info);
top=top->next;
}
printf ("NULL");
}
struct elem *writeFile (FILE *fp, struct elem *top)
{
int sum=0;
struct elem *prec, *curr, *tmp;
for (prec=top;prec!=NULL;prec=prec->next)
{
for (curr=prec->next;curr!=NULL;)
{
if (curr<prec && prec<curr)
{
tmp=curr;
curr=curr->next;
free(tmp);
}
else
curr=curr->next;
}
{
sum=sum+prec->info;
fprintf (fp,"%d ",sum);
}
}
return sum;
}
Oleksandr
Are we need to handle smth like:
input: 1 2 4 6
3 4 6 -> 7 6 -> 13
output: 13
?
Crescenzo
The exercise also requires use of File, so I read from File, insert it in the list and the result I write it to File.
Anonymous
Check this...very basic implementation I wrote
Crescenzo
No Alessandro, consider this example:
Example:
1, 2, 5, 13, 7, 8, 23
Output (with sum subsequence):
3, 5, 13, 15, 23
Anonymous
Crescenzo
Perfect, but I can't use other structures, only Linked LIST!
Crescenzo
I had also thought of using a backing array, but it's not possible.
Anonymous
Crescenzo
Yes I know, that part of the code was confusing, I wanted to give you an input.
Anonymous