Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: [edited] collision response in a RTS Pin
Gerry Schmitz1-Sep-23 6:26
mveGerry Schmitz1-Sep-23 6:26 
GeneralRe: [edited] collision response in a RTS Pin
Calin Negru2-Sep-23 7:35
Calin Negru2-Sep-23 7:35 
GeneralRe: [edited] collision response in a RTS Pin
Gerry Schmitz3-Sep-23 5:30
mveGerry Schmitz3-Sep-23 5:30 
QuestionDSA Pin
ZAID razvi25-Aug-23 0:50
ZAID razvi25-Aug-23 0:50 
AnswerRe: DSA Pin
CPallini25-Aug-23 1:36
mveCPallini25-Aug-23 1:36 
GeneralRe: DSA Pin
ZAID razvi25-Aug-23 1:54
ZAID razvi25-Aug-23 1:54 
GeneralRe: DSA Pin
CPallini25-Aug-23 2:10
mveCPallini25-Aug-23 2:10 
GeneralRe: DSA Pin
ZAID razvi25-Aug-23 4:57
ZAID razvi25-Aug-23 4:57 
How is that possible sir! Second code is written by a renowned youtuber 'code_with_harry'. Okk, for your better understanding i'm pasting full source code here:


#include <stdio.h>
#include <stdlib.h>

struct Node *f = NULL;
struct Node *r = NULL;

struct Node{
int data;
struct Node *next;
};
void traversal(struct Node *f){
struct Node *ptr=f;
printf("------------\n");
while(ptr!=NULL){
printf("%d ",ptr->data);
ptr=ptr->next;
}
printf("\n------------\n");
}
int isEmpty(struct Node *f){
if (f == NULL){
return 1;
}
return 0;
}
int isFull(struct Node *f){
struct Node *n = (struct Node *)malloc(sizeof(struct Node));
if (n == NULL){
return 1;
}
return 0;
}
struct Node *enqueue(int val){
if (isFull(f)){
printf("Queue Overflow! Can't Enqueue %d\n", val);
return f;
}
else{
struct Node *n = (struct Node *)malloc(sizeof(struct Node));
n->data = val;
n->next = NULL;
if (isEmpty(f)){
f = r = n;
}
r->next = n;
r = n;
return f;
}
}
// int dequeue(){
// if (isFull(f)){
// printf("Queue Underflow! Nothing to Dequeue");
// }
// int dqd = f->data;
// f = f->next;
// return dqd;
// }
int dequeue(){
int val=-1;
struct Node *ptr=f;
if (f==NULL){
printf("Empty\n");
}
else{
f=f->next;
val=ptr->data;
free(ptr);
return val;
}
}
int main(){

enqueue(11);
enqueue(22);
enqueue(33);
enqueue(44);
traversal(f);

dequeue();
dequeue();
traversal(f);

return 0;
}
GeneralRe: DSA Pin
Richard Deeming28-Aug-23 21:34
mveRichard Deeming28-Aug-23 21:34 
GeneralRe: DSA Pin
ZAID razvi28-Aug-23 21:52
ZAID razvi28-Aug-23 21:52 
GeneralRe: DSA Pin
Andre Oosthuizen29-Aug-23 2:41
mveAndre Oosthuizen29-Aug-23 2:41 
GeneralRe: DSA Pin
Richard Deeming29-Aug-23 3:11
mveRichard Deeming29-Aug-23 3:11 
GeneralRe: DSA Pin
Richard MacCutchan28-Aug-23 21:56
mveRichard MacCutchan28-Aug-23 21:56 
GeneralRe: DSA Pin
Dave Kreskowiak29-Aug-23 2:04
mveDave Kreskowiak29-Aug-23 2:04 
GeneralRe: DSA Pin
Richard Deeming29-Aug-23 3:12
mveRichard Deeming29-Aug-23 3:12 
GeneralRe: DSA Pin
CPallini30-Aug-23 2:57
mveCPallini30-Aug-23 2:57 
QuestionInvalid application of 'sizeof' to incomplete type 'struct Node' Pin
ZAID razvi22-Aug-23 20:20
ZAID razvi22-Aug-23 20:20 
AnswerRe: Invalid application of 'sizeof' to incomplete type 'struct Node' Pin
Victor Nijegorodov22-Aug-23 20:41
Victor Nijegorodov22-Aug-23 20:41 
GeneralRe: Invalid application of 'sizeof' to incomplete type 'struct Node' Pin
ZAID razvi24-Aug-23 23:45
ZAID razvi24-Aug-23 23:45 
AnswerRe: Invalid application of 'sizeof' to incomplete type 'struct Node' Pin
CPallini22-Aug-23 21:06
mveCPallini22-Aug-23 21:06 
PraiseRe: Invalid application of 'sizeof' to incomplete type 'struct Node' Pin
ThatsAlok23-Aug-23 17:01
ThatsAlok23-Aug-23 17:01 
GeneralOT Pin
CPallini23-Aug-23 19:59
mveCPallini23-Aug-23 19:59 
GeneralRe: Invalid application of 'sizeof' to incomplete type 'struct Node' Pin
ZAID razvi24-Aug-23 23:43
ZAID razvi24-Aug-23 23:43 
GeneralRe: Invalid application of 'sizeof' to incomplete type 'struct Node' Pin
CPallini24-Aug-23 23:47
mveCPallini24-Aug-23 23:47 
Questionconversions in 64 bit mode Pin
utcode21-Aug-23 18:35
utcode21-Aug-23 18:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.