WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I got it work somewhat how do i remove the extra * and add spaces in between.

What extra * and add spaces where?

Try drawing out your cone on graph paper for different rocket widths. Then look at the pattern for number of spaces in each line and where the *s are. There will be a definite number progression which is easily coded.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hold on, bucko! Not getting help? Let's recap:

You know you can't define a function within another function, don't you? If you properly format your code, the error will jump out at you immediately.

Yes, I do realize that I was having trouble finding where it was done. [formatting was hindering you]

one more thing, use proper indentation to make the code clearer and more readable. Wherever you start open a brace "{" you need one level of indentation.

The only thing I can find at that link that hasn't been done in my program yet is the indentation of { and } and the separate indentations. I have read it twice and don't feel that it is such a huge issue that I have to fix that before the other errors as I am reformatting some of the things later anyways once I get it to fully compile

Even thought group256 told you reformatting will help, and I told you reformatting will answer your question, you told us you know better. Then you got help from an obvious hack that completely screwed up all your formatting. He also helped you use questionable coding practices.

There's obviously nothing I at least can help you with. I can't read your code, and you refuse to make it readable.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The C++ Standard requires main() to be int. void is just plain wrong.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I had a glitch that didn't allow me to add additional info.

This is not the place to teach recursion, but you can easily find out about it using a simple search. In a nutshell, recursion is a memory hog and if used improperly it can suck up your entire memory.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Probably not...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Do not use recursion at all. Period. Use a loop.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Does your draw cone function consider the width of the rocket?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Use a combination of:
LEFT function
String Length function

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Answering a C question with C++ is worthless. And using gets() and getch() is so wrong it's close to criminal.

And do I really need to mention CODE Tags? The Member Rules are quite clear...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Did you read my previous post?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Why are you specifying a function prototype string wordtobold( temp2.substr(prev_pos, pos-prev_pos) ); instead of calling the function wordtobold( temp2.substr(prev_pos, pos-prev_pos) ); :icon_question:

How do you know the getline() call is returning TRUE?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

How would I load the private data here?

Here? Where?

Where to you actually read the data? Where is the data at that time? Where do you want it?

And then-where would I put the 'get' values and how?

Where you need them. There's a possibility you won't need them. But then again...

This was my original question...I was trying to do that in main, but didn't know the syntax.

You can't just put something any ol' place just because you think you need it. You need to think it through and analyze what you are trying to accomplish. Answer the problem by writing down the steps you go through to solve it, then look at how to convert those steps into code.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

In other words, add the line using namespace std; after your header.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Is your output Blank or nonexistant?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Lerner, you know what they say about great minds.... :)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

This is a solution but it does not work at all times and I can't find a logical flow in the code.
Any ideas?

Output key values during the execution to see if the program is behaving as you think it is. Try to pinpoint the area you have the flow...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Start by reading the first file and displaying the line
Next, search for the "CCD"
Then copy the rest of the line to another string
Now display that new string to be sure you extracted it correctly

Repeat until you get to the end of the file.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Please format your code better. It's hard to read with the formatting you have used.

In setWidth() and setLength() you read in the values but did not load the private data. So your values in the class are junk.

Then, right after each set you call get and throw away the value you got by not putting it anywhere. Both get s are wasted calls.

Then you call area() with uninitialized local values for length and width. Shouldn't area and perimeter use the values stored in the class, not passed in values? After all, you're trying to get the values for MyRectangle , not just any ol' rectangle.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Start by opening the input file, read each line/word and output it to the screen. When file is done, close the file and exit.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Since the lines in question are 52 and 256, and you posted only 40 lines, it's impossible to tell.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Thanks for the reply.

But once you converting string which has fixed value. Then how it can be treat as different value? I know it is not different value but i want to understand why exactly it is happening like this.

Did you try the search?

Is there anything do with the gcc compiler?

No.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You can't. You need to read old and write new.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

It says the error is in main on line 61. Might be a good idea to show us that line.

Also string filename = Work.Title += ".txt"; should be string filename = Work.Title + ".txt"; I believe. I doubt you want to change Work.Title

WildBamaBoy commented: Good eye! +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Not with that attitude it won't :icon_twisted:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Because floating point numbers are approximations. Digital values cannot represent real numbers exactly. Search the web for explanations of how they work.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

1) Use CODE Tags
2) Format your code -- see this
3) main() is not a void function -- see this
4) Execute your loop with pencil and paper to see what it's doing. Concentrate on the IF statement as you do.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Since we can't see what you tried, and, to be honest, I have no idea what you're trying to do since cout is so easy to use, back up and give us a clear, precice explanation with an clear example.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Your best bet is to ask your instructor. Since he's requiring you to use Turbo C, he's your best resource to fix the problem.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Shouldn't the input be more along the lines of:

sum = 0
+ 12
sum = 12
- 2
sum = 10
+ 5
sum = 15

It doesn't make sense to me to have a full equation added to the sum.

Intrade commented: I was thinking that too, but he specified different (and misunderstood) requirements XD +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Calling a class function is identical to calling a regular function.

Please learn to format your code to make it understandable and use CODE Tags.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Why would you want to "display" the question "in another text file"? Don't you need it on the screen so the person can read the question and answer it?

For your struct, what do you think you need in it?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Since we aren't in you head, it's really hard for us to know where you're going. The only thing I can really tell you is your set functions should not input values. They should only set the private var with the value passed into the set-functions. Do the input in the main code or, better yet, a function that main calls.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yes I could but that's like transforming a 2010 Mercedes Benz into a 1975 Ford Pinto. Why would you possibly take a good construct and turn it into an extremely bad construct?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Major thing to correct is formatting. You have none. Because of that your code is too hard to follow.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You're writing C which simulates a string with a character array. You can't use = to assign arrays. Look up string.h functions...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
for(int i=0; i<size; ++i)
	{
		if(text[i] == '\n')
			height += 1;
	}

If there are \n characters in your text array, this loop will count them. Is height initialized properly?

for(int i=0; i < size; ++i)
	if(text[i] != '\n')
		width += 1;

All this does is count the number of non-\n characters in the buffer. Should be size - height

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Look very carefully at line 13:

while(a[i] != '\n'|| i != 80)

Think about the truth table this statement generates.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I assume you've seen this but just in case...

I only know the console functions so I don't think I can help.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

With what? Your description was so convoluted that we have no idea exactly what you are trying to do, just a bunch of half descriptions of what you don't want to do.

Be specific.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Instead of:

for ( int j = 2; j <= num; j++){

use

for ( int j = 2; j <= sqrt(num); j++){

This will shorten the run time by a large magnitude.

Regards,
Ubaidullah Nubar.

No it won't, Every time you go through the loop, sqrt(num) will be recalculated. If you want to shorten the run time, use:

sq = sqrt(num);
for (j = 2; j <= sq; j++){
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Help with what? 169 lines and not on;ly are we supposed to guess what lines have errors, but we have to guess the errors too?

What's the first question your instructor will ask if all you say is "I have a problem"? Answer the question when you post to save time...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If statement.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Good for you! Next time, use CODE Tags, though.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Here's the deal. I've been programming for over 30 years. Formatting is ultra important. I don't give a rats what you think about it. If you don't start formatting from the first line of code written to the last, you are not a programmer. Period.

I'm done here. You can't follow instructions, I can't help.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I don't see where you loaded any values into the timer object.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

That's is the exact issue. Your code does not flow properly without proper indentation. It takes 10 minutes to do and you've wasted 7 hours by not doing it.

I know exactly what your problem is but without the formatting you can't see it and it's too complicated to explain.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

We were in the final season last season....

Anyway, when should Smallville end, when Welling is 50? We need a Superman long before then! He's already 33!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I'm 12 and I say 'back in my day' to little 1 year old ▲_▲
:P

And you really know you're in trouble when a 1-year-old understands what you mean.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You didn't bother to follow the link I posted, I can tell. If you can't follow simple formatting instructions, you won't be able to follow the complex code changes necessary to fix what you currently have.

Click on the link and learn, please:

You know you can't define a function within another function, don't you? If you properly format your code, the error will jump out at you immediately.