I have a flow on how to do this program but I need so help. PLEASE GIVE ME A HINT NOT THE ANSWER.

THE FLOW CHART IS IN THE ATTACHMENT. PLEASE CHECK IT OUT BEFORE GIVING HINTS

/***************************************************
  The following program will take user's input 
  and check whether it is in the following language:

    <S> --->  a <B> | <A> | b
    <A> --->  c <A> |  c
    <B> --->  d | <A>
****************************************************/


#include<iostream>
#include<string>
using namespace std;
#include<stdlib.h>  // for the exit(1) function 



char* SProd(char* ThisOne ); // <S> --> a <B>  | <A>  | b
char* AProd(char* ThisOne ); // <A> --> c <A>  | c
char* BProd(char* ThisOne ); // <B> --> d      | <A>
char* XProd(char* ThisOne, char x);

int main()
{
	

	string text; 
	char *ThisOne;

	// cout<<"Enter a string"<<endl; 
	// cin>>text;

	 cout<<"Enter a string"<<endl;
	 cin>>text;



	 *ThisOne = text.begin();
	 ThisOne = SProd(ThisOne);

	

	if(*ThisOne== '\0')  //Check whether there is an extra character at the end
		cout<<"valid"<<endl; 
	else 
		cout<<"Invalid"<<endl;
	system("pause");          
   	return 0; 
}




char* XProd(char* ThisOne, char x)
{
		ThisOne = XProd(ThisOne, 'a');
		ThisOne	 = XProd(ThisOne, 'b');
		ThisOne   = XProd(ThisOne, 'c');
		ThisOne	 = XProd(ThisOne,  'd'); 
}

 // <S> --> a <B>  | <A>  | b
char* SProd(char* ThisOne )
{
	if (*ThisOne == 'b')
	{
		ThisOne++;
		return ThisOne; 
	}

	else { 
		if (*ThisOne == 'a')
	{
		ThisOne++;
		 ThisOne = BProd(ThisOne);
		 return ThisOne; 
	}
		else
		{
			 ThisOne = AProd(ThisOne);
			 return ThisOne; 
		}
	}
}





// <A> --> c <A>  | c
char* AProd(char* ThisOne)
{
	if(*ThisOne != 'c')
	{
		cout<<"Invalid"<<endl;
		exit(1);
	}
	else
	{
		ThisOne++;
		while (*ThisOne == 'c')
			ThisOne++;
			return ThisOne;
	}



}


// <B> --> d      | <A>
char* BProd(char* ThisOne) 
{
	if(*ThisOne = 'd')
	{
		ThisOne++;
		return ThisOne; 
	}
	else
	{
		 ThisOne = AProd(ThisOne);
	}

}
spoonlicker commented: Threatened me. +0

Recommended Answers

All 22 Replies

I'm sorry it's too hard for me to understand.

I'm sorry it's too hard for me to understand.

It's ok. Thanks for trying. :)

It's ok. Thanks for trying. :)

Are you saying you're smarter than me?

commented: Troll -1
commented: Big Troll +0

Are you saying you're smarter than me?

:?: No, I just saying thanks for trying.

:?: No, I just saying thanks for trying.

That's what I thought.

Watch what you say.

That's what I thought.

Watch what you say.

:icon_evil: Shut the hell up <SNIPPED>!!!

commented: No need for this -1

KEEP IT PLEASANT

@Transcendent mind the language

@spoonlicker do not post if you do not know answer or if you do not have reasonable suggestion. Also do not post to attack people. Next time read carefully reply "It's ok. Thanks for trying." is nothing personal, Transcendent was actually polite thanking you for even looking at his problem.

Take this as unofficial warning, next misbehaviour will come with "reward" according to forum rules.

commented: Whip them, yeah! +6

You've followed the flow chart well, though you have a typo in your bProd function.

Hint: There's a difference between unary and binary operators.

Hint2: Is everything in your code being put to use?

commented: Thanx for tips :) +16

@Transcendent and @spoonlicker it doesn't mean that you two can go on with abusing reputation system

@OTHERS no need to down repute either of them, both made mistakes hopefully they will learn from it

I can't really see where you're going but there's a flaw in function Xprod() at line 54.You are assigning to ThisOne the return of the function Xprod() which should return a char* but instead it returns nothing.Could be the problem so check it out

can someone tell me how to fix this:

error: cannot convert '__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >' to 'char' in assignment|

can someone tell me how to fix this:

error: cannot convert '__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >' to 'char' in assignment|

I know this is off-topic, but why did you assume I was male?

I know this is off-topic, but why did you assume I was male?

Unless you're talking about the snipped profanity, I don't see any such assumption in this thread. But it's generally a good assumption on this kind of forum. It's also easier to make an assumption and go with it than writing in a gender neutral manner. Finally, your attitude does suggest a younger male.

commented: yup +5

I know this is off-topic, but why did you assume I was male?

@licker as Peter said: do not post if you do not know answer or if you do not have reasonable suggestion

It may be because you're using pointers instead of string iterators.

Finally, your attitude does suggest a younger male.

Ah, finally...Here comes the drumroll.... *drumroll*

Generalization.

Assuming a certain attitude is prominent in ones' gender rather than a bigger generalization of teenagers as a whole.

You're dead wrong in thinking bad attitude is mainly associated with males.

If you think that then you clearly don't deal with teenagers.

I'm highly offended and actually hurt by hearing how you'd just mindlessly make a generalization that only a male has a bad attitude, and a young one at that.

This is definitely off-topic, but I am highly offended by what you said and I'm not trying to ruin the flow of the question I just want you to respond back with some answers to why you made such a generalization targeting males and demeaning the outlook of them rather than teens as a whole, being immature mostly.

Again, I'm offended. VERY offended by what you said. You shouldn't make hurtful generalizations like that that are untrue and biased.

You're dead wrong in thinking bad attitude is mainly associated with males.

It's not as much a bad attitude as being competitive and quick to lash out at perceived insults. Your behavior strikes me more as that of the average teenage dude.

I'm highly offended and actually hurt

I couldn't care less if you're offended or not.

I want an answer for your reason.

It's not as much a bad attitude as being competitive and quick to lash out at perceived insults. Your behavior strikes me more as that of the average teenage dude.

Why so? Lashing out insults is associated with stupidity, ignorance and arrogance and that's common with both genders in teenagers.

I couldn't care less if you're offended or not.

You'll get it for saying that. You're gonna pay some how, I guarantee it. To come on this site and have to hear some one as ignorant as you make biased claims and then say you don't care if I'm offended or not proves what kind of person you are.

commented: You're hilarious. -5

> I want an answer for your reason.
And I want you to cease this completely useless and off-topic hijack of the thread. This isn't the place to discuss your hurt feelings.

Get it back on topic.

commented: Thanx for stepping in, I was on bus and mobile is bad for moderator needs +16

> I want an answer for your reason.
And I want you to cease this completely useless and off-topic hijack of the thread. This isn't the place to discuss your hurt feelings.

Get it back on topic.

Sorry, I'll stop getting in the way.

@Transcendant: If you are still having trouble with making this program work, I suggest you create a fresh new thread for it (because this thread seem to have about two posts related to the question out of 25 or so). I'm sorry (on "behalf" of daniweb) for the flame war that occurred on this thread. It is the first time I see this happen on this forum, and I hope it will not discourage you from posting questions again.

commented: Cool +6
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.