i want to write this program without lib and string files make changes in it and tell me the program thanks code is below

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
struct Node;
typedef struct Node * PtrToNode;
struct Node
{
    char element;
    PtrToNode Next;
};

PtrToNode MakeEmpty(PtrToNode L)
{
    L= new(Node);
    L->Next=NULL;
    return L;
}

void Push(PtrToNode L,char x)
{
    PtrToNode S;
    S= new(Node);
    S->element=x;
    S->Next=L->Next;
    L->Next=S;
}

char Pop(PtrToNode L)
{
    PtrToNode P;
    P=L->Next;
    char x=P->element;
    L->Next=P->Next;
    free(P);
    return x;
}
int main()
{
    PtrToNode L;
    L= MakeEmpty(NULL);
    char Input[1000];
    int i;
    printf("please enter your equation:");
    scanf("%s",Input);

    for (i = 0;i<strlen(Input);i++)
    {
	if (Input[i]=='(')
	{
	    Push(L,Input[i]);
	}
	if (Input[i]==')')
	{
	    if (L->Next==NULL)
	    {
		printf("incorrect");
		return 0;
	    }
	    else
		Pop(L);
	}



    }
    if (L->Next==NULL)
	printf("correct");
    else
	printf("incorrect");
    getch();
    return 0;
}

Recommended Answers

All 8 Replies

>>i want to write this program without lib and string files

Not possible. You need standard C libraries in order for your compiler to produce the executable program. If you don't want any libraries then you have to first delete (remove) all those header files in lines 1 to 4, then write your own version of malloc(), free(), printf(), etc. Or maybe that wasn't really what you want. If not, then you will have to provide more information.

Remember, we will not write your program for you. Ask specific questions and we will try to answer them.

--> arrow like this what they are working?? i neva use in my c code.

--> arrow like this what they are working?? i neva use in my c code.

You need to read and study pointers. This link is a good tutorial

i understand a little bit BUT take a look of this

#
char Pop(PtrToNode L)
#
{
#
PtrToNode P;
#
P=L->Next;
#
char x=P->element;
#
L->Next=P->Next;
#
free(P);
#
return x;

the lines which have --> what actually this operation is working?? is this doing like assigning a value or what ??

You need to read and study pointers. This link is a good tutorial
-- Ancient Dragon

i made this for balancing the paranthesis but it is not working plz make it correct thanks

int main(){
char i,input[30],close,open;
for(i=0;i<='.';i++){
printf("enter equation");
scanf("%c",input[i]);
if(input[i]=='(')
input++;
input[i]=open;
else if(input[i]==')')
input[i]--;
input[i]=close;
else if(open[i]==close[i])
{
printf("paranthesis are balance");
}
else
printf("paranthesis are not balance");
}

getch();
return 0;

}

I'm going to assume the above post was posted by mistake since a new thread was started with the same code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.