#Why am I getting a different output in VSC ??
27 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
Im getting the output like this in VSC
Let me send in text form also
#include <stdlib.h>
struct node{
int data;
struct node *next;
};
struct node *head;
void insert_end(){
int n;
printf("Enter value to insert at the end: ");
scanf("%d", &n);
struct node *temp, *ptr;
temp = (struct node*)malloc(sizeof(struct node));
if(head == NULL){
head = temp;
head -> data = n;
head -> next = NULL;
}
else{
ptr = head;
while(ptr -> next != NULL){
ptr = ptr -> next;
}
ptr -> next = temp;
temp -> data = n;
temp -> next = NULL;
}
}
void insert_beg(){
int n;
printf("Enter value to insert at the beginning: ");
scanf("%d", &n);
struct node *temp;
temp = (struct node*)malloc(sizeof(struct node));
if (head == NULL){
head = temp;
head -> data = n;
head -> next = NULL;
}
else{
temp -> next = head;
head = temp;
head -> data = n;
}
}
void insert_mid(){
int n;
int d;
printf("Enter particular value to insert after: ");
scanf("%d", &d);
printf("Enter value to insert at the middle: ");
scanf("%d", &n);
struct node *temp, *ptr;
temp = (struct node*)malloc(sizeof(struct node));
ptr = head;
while(ptr -> data != d){
ptr = ptr -> next;
}
temp -> next = ptr ->next;
ptr -> next = temp;
temp -> data = n;
}```
struct node *temp;
temp = head;
if (temp -> next == NULL){
free(head);
printf("The last value is deleted\n");
}
else{
while(temp -> next -> next != NULL){
temp = temp -> next;
}
free(temp -> next);
temp -> next = NULL;
printf("The last value is deleted\n");
}
}
void delete_beg(){
struct node *temp;
temp = head;
if (temp -> next == NULL){
free(head);
printf("The first value is deleted\n");
}
else{
head = head -> next;
free(temp);
printf("The first value is deleted\n");
}
}
void delete_mid(){
int d;
printf("Enter value to delete: ");
scanf("%d", &d);
struct node *temp1, *temp2;
temp1 = head;
while(temp1 -> data != d){
temp2 = temp1;
temp1 = temp1 -> next;
}
temp2 -> next = temp1 -> next;
free(temp1);
printf("The given value is deleted\n");
}
void update(){
int n;
int d;
printf("Enter value to update: ");
scanf("%d", &d);
printf("Enter new value: ");
scanf("%d", &n);
struct node *temp;
temp = head;
while(temp -> data != d){
temp = temp -> next;
}
temp -> data = n;
}
void display(){
struct node *temp;
temp = head;
while(temp -> next != NULL){
printf("%d\t", temp -> data);
temp = temp -> next;
}
printf("%d\n", temp -> data);
}```
{
int choice;
while(1){
/*printf("1. Insert at the end.\n");
printf("2. Insert at the beginning.\n");
printf("3. Insert at the middle after a particular data.\n");
printf("4. Delete at the end.\n");
printf("5. Delete at the beg.\n");
printf("6. Delete at the middle after a particular data.\n");
printf("7. Updating a particular value.\n");
printf("8. Displaying the data\n");*/
printf("enter choice: ");
scanf("%d", &choice);
switch(choice){
case 1:
insert_end();
break;
case 2:
insert_beg();
break;
case 3:
insert_mid();
break;
case 4:
delete_end();
break;
case 5:
delete_beg();
break;
case 6:
delete_mid();
break;
case 7:
update();
break;
case 8:
display();
break;
case 9:
exit(0);
default:
printf("invalid choice");
}
}
return 0;
}
What sequence of actions causes this output
What is different about how you were running the code outside of vsc
Im able to run it properly without any issues in online compiler
Can you show the part of the code that is printing this message
Theres no enter an operation in my code
So your code is not running then
it still printing this would suggest that you're not saving your code, not recompiling it, or both
Ive saved it
How do i recompile ??
that's a hard question to answer with VSC because there's no built-in or standard way of doing it, since it's all done through plugins or external tools
if you've got it properly configured, the green play button should do it
Im getting it now
I just deleted those on the right hand side
The code and the debug thing