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

let me know what you think

Terrible. Never call main() !!!! Use a loop. And CODE tags. They were mentioned in the rules you read when you registered. (You did read them, didn't you?)

Also, you have no repetition, no user defined functions, and no option to quit. You didn't follow the design required.

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

Did you try my suggestion? Output various values at key spots in the program to see what values are not as expected.

will, when i enter s or S my loop should said ok you picked function square, now move on and chose two numbers.

but what really happen here is when i enter s or S, my loop said sorry wrong choice enter again.
and my program wasn't able to perform the square function that i want it to do.

For the third time DID YOU TRY MY SUGGESTION? OUTPUT YOUR VARIABLES!!!

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

I also have values that need rounding down to get to the nearest like..whole number. Im amazed c++ dosnt have a function that can round to the nearest whole number, regardless of whether it needs rounded up or down.

Thanks for your posts

The sine of 180 is 0. What's the problem?

I also have values that need rounding down to get to the nearest like..whole number. Im amazed c++ dosnt have a function that can round to the nearest whole number, regardless of whether it needs rounded up or down.

Thanks for your posts

Why? It's trivial. Languages don't need a function for every insignificant math concept.

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

Or, a little easier:

int main ()
{
   float b;
   float f = 123.457678F;

   float b = (int) (f + 0.5);
   cout << b;
   return 0;
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Only around your code. And it needs to be formatted code.

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

What values are in the compe array?

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

3)i entered this
input output
2 wrong input
a wrong input
s wrong input
q quit

Did you try my suggestion? Output various values at key spots in the program to see what values are not as expected.

4)when i enter q the i am surprise program ends, but when i enter s or any of the characters in the option i offer my loop will keep re promote for another input why.

I'm still wondering why you are surprised the program ends. Isn't that what Q and q mean? You did something right, it seems.

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

what should i do to get the output i wish?

By reading the Rules, which has been suggested many times to you already. And you obviously missed Read Me: Read This Before Posting too.

pls help me ... im newbie .... just study c++ for a few week...

And how many times do we have to be reminded of this? We really don't care.

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

What part of "Use code tags" did you not understand? (http://www.daniweb.com/forums/post479400-2.html)

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

So what have you figured out?

Didn't you read the Rules and Read Me: Read This Before Posting yet?

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

Cool Narue! I didn't know that. (I suppose that's the kind of brain damage I get for having tried it years ago on some silly, ancient, broken DOS C compiler.)

Doublex, how about this one: printf( "%s", strcpy( "Stupider", "Stupid" ) ); (results may vary).

Results may crash!

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

Try commenting your code. That would tell you quite a lot, if you comment exactly.

Based on your code:

if ((input = fopen("infile", "r")) !=NULL)    // open the file
   {
   
        while ((fileInput = fgetc(input)) != EOF)    // read a single character
            {
                strcpy(input, word);     // copy WORD into INPUT
   
                putchar(fileInput);     // Output the character read
                fillArray(word);
            }

You never did anything with the single character you read. And you never read any more than that.
Isn't INPUT a file designator? Does strcpy() work on such an item? Look it up. I know your compiler complained about that.

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

any in sight would be helpful. im really under the gun and have been trying to get this to work for a couple of days.

thanks in advance
David

With what? You didn't mention anything was wrong. Did you read the post titled
Read Me: Read This Before Posting?

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

When are the old-style smilies gonna become obsolete? I say they should be, otherwise I might question why there was any point of having the new smilies commissioned.

agreed

Disagree.

I don't think the original smilies are consistent with the style of the rest of the site. You should get rid of them.

People who don't like it, need to get used to change. Seeing as 'smilies' do not serve any purpose (from a pragmatic P.O.V) you can do this without fear of any reprisals, since none of the complaints would be taken seriously or have any substance.

We're programmers. we're already used to change. We just dislike the new smilies for various reasons.

There's a couple of the old smilies that don't exist in the new crop of cmilies, such as embarrased and the big green grinning face. So my vote is to leave them as they are now.

You forgot WINK and ROLLEYES. The current WINK is bad and cannot be distinguished from TONGUE. Using it gives the wrong message.

Dani could implement a couple that I made. They're on the other site, but not here.

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

Look up the fmod() function to replace the % operator.

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

I just couldn't believe there wasn't one already.

I'm curious. Why would you think there's a function to remove spaces from a string? Of what use would such a function be in the real world? :?:

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

Output various values as the program runs and see what variables don't contain values you're expecting.

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

Add header time.h and make a loop that gets the current time using time() . You can then test if the time has changed and output it.

By the way, if you are going to use 90% C (and old non-standard C at that) you should just make a C program by converting the cout to printf() and remove iostream

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

Talk about thread bombing! A full 2/3 of the posts have been made by nicz888, the OP. I for one can't follow the progress here because of multiple posts of 200 line programs. I have no idea what the problem is.

2) if i take line 77-92 away.
if i enter q the program will end
if i enter s it will prompt me to enter low and upper bound
if i enter s, 1, 2, 0 and 0
it will brings me back to the original prompt i can choose s,c,f....q.
when i enter q or Q. the program did end why is that???

Probably because Q or q means quit?

Sturm commented: You have some pretty insane intiution(sp) +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Look up the bubble sort. It's much easier than the selection sort.

Comments such as "you have no idea what you are doing", "you shouldnt code this or that its horrible" are NOT welcome.

Im learning - you all learnt at some point too. So let me work at it. I'll get there. Just have some patience!

Touchy, aren't we? Has this happened a lot to you in 14 posts?

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

If you get 42, the universe will end!

Hopefully, you code uses 2 nested loops -- FOR loops are best.

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

See the comment I added at the bottom of the code

int main()
{
   length = strlen(string);
   boolean = IsPalindrome(string, 0, length);
...
}

int IsPalindrome (char* string, int left, int right)
{
   if (left >= right)
   {
      return TRUE;
   }
   if (string == string)
   {
      return IsPalindrome(string, left+1, right-1);
   }
   if (string != string)
   {
      return FALSE;
   }      
   //// The compiler is complaining about no return 
   //// statement here.  It can't tell that the program 
   //// can't reach this point.
}

As a matter of fact, the last IF is not needed at all. If the previous IF ( if (string == string) ) fails, the strings are automatically !=, isn't it? Also, when can string ever be not equal to string ? They are the same variable, therefore they MUST be equal!!!

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

However you want to make the file you want to read. Notepad is fine for text files. You can also write a program that accepts info from the user and writes it to a file for another program to read.

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

let me put it this way about 17000 lines in the file take up to 1 to 1.5 megabytes so if i do as u suggested...even in this case i would need around 17000 * 1000 matches in most cases... and 17000*17000 matches in worst case only for 1/50 th of the file :(

Let me put it this way -- leaving out important information makes it hard to give good help.

i wonder if ancient dragon is online ...he would have solved this in a minute....:(

This certainly doesn't make anyone else here feel like helping. Sorry we're all such poor programmers. I have another option, but I guess you won't like it, either. He's all yours, AD...

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

Here are some problems you should fix:

#include <cstdlib> 
#include <ctime> 
#include <iostream>

using namespace std; // prototype and name space declaration
bool testAnswer(int, int, int);  
void correctOutput();
void incorrectOutput();
bool mathTest();

//------------------------------------------------------------------
//------------------------------------------------------------------
//------------------------------------------------------------------

int main()
{
	if (mathTest())    // Just call mathTest.  This IF is really confusing...
	{
		!(mathTest());   // especially this stuff.  What are you trying to do?
		mathTest();

	}
}

bool mathTest() //main function 
{ 
    srand((unsigned)time(0)); // random number generator 
    // srand should be called only once.  Put it at the beginning of main

    int random_integerA, random_integerB; 
	int input;

    for(int index=1; index<=2; index++){  
		if (index == 1)
			{
			random_integerA = (rand()%10); 
			}
		else
			{
			random_integerB = (rand()%10);
			}
	}
// The above FOR loop can be written as:
        random_integerA = (rand()%10); 
        random_integerB = (rand()%10); 
// There is no reason for a loop.

        cout << random_integerA ; 
		cout << " * ";
		cout << random_integerB ; 
		cout << " is: ";
		cin >> input;
			
		if (testAnswer(random_integerA, random_integerB, input))
			{
				correctOutput();
			}
			else
				incorrectOutput();

		while(testAnswer(random_integerA, random_integerB, input) != true)
		{

			
				cout << random_integerA ; 
				cout << " * ";
				cout << random_integerB ; 
				cout << " is: ";
				cin >> input;

			if (testAnswer(random_integerA, random_integerB, input))
			{
				correctOutput();
				return true;
				mathTest();    // After you return, you can never reach this statement
				break;
			}
			else
				incorrectOutput();
	
     
}}

//------------------------------------------------------------------
//------------------------------------------------------------------
//------------------------------------------------------------------

bool testAnswer(int numA, int numB, int inputNum) // 
{
	if ( numA * numB == inputNum)
		return true;
	else
		return false;
}
//------------------------------------------------------------------
//------------------------------------------------------------------
//------------------------------------------------------------------
void correctOutput() // display …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

So type the CODE tags in or hit "GO ADVANCED". Don't just make a rotten post because the Quick Reply box isn't perfect for you...

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

I guess we need to know your native language. You obviously don't read English well enough to understand our posts.

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

hehe....u free....can help me solve my problem??

You waited an entire 9 minutes before bumping your post? C'mon, we don't live on this board.

Read the entire file into an array of strings and loop through them.

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

If you get errors, the technique to get help is to post the errors exactly as you see them (cut & paste, don't retype).

Based on he code snippet you posted, you are only missing the randomizer srand() .

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

> What the heck is an erm.

:$ Oh, urgh, um... Exchange Rate Mechanism, Enterprise Resource Management, Erase Reserved Memory, Electronic Rodent Monitoring, Earth Resistance Meter, uh...

:)

Oh, of course. I thought I was a verbal expression that has no place in writing. Silly me! :icon_wink:

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

hi
plz help me overcome a few errors in my encryption project....
thanks

Such as?

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

i want to to able to access to a class's vairable but this varible is not declared class's header file
it is in the cpp file i couldn't write a method that acces to it because methods cannot access it(since the variable is not in the header file) how can i solve this problem

I don't know what your native language is, but in English we have things like periods (.) to end a sentence so you can communicate effectively. Try using them, please. Oh, and that was a comma (,) -- also useful.

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

so in this code you have displayed....

...

The first part of it would have to be up near the top of my old code...

...

Is that about right? if not then i am still lost

This is why you should not post code without explaining what you're doing. The OP rarely has an idea how to cut and paste your code into his project and have it work.

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

Aren't the posts

Read Me: C++ Books
Read Me: C / C++ FAQ's and Practice problems

helpful?

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

i`ve a question regarding stack and queue...

So start your own thread, don't hijack someone else's thread.

its as to implement queue and stack on these
data: 23,34,56,67,89,90
using linklist....can anyone tell me how to begin..

Read the rules and other important sticky posts, make your own thread, and tell us which you want -- stack, queue, or linked list.

Erm,

What the heck is an erm?

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

Need to Modify my codes to include a function for both A and B. The function for A should have the quantity of numbers passed in as a parameter and needs to return the largest number.

An array would be the easiest way to handle this. Load the numbers in the array, pass the array and the number of values to the function.

The function for B should have no parameters and return the smallest number.

Maybe for this one you have to read the values in the function.

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

im confused as to how to write an error checking function and how to write a decode function which decodes morse code. It cannot simply be a backwards of the encode function because ONE morse code is made up of FOUR characters...? (if you get what i mean?) i am not allowed to use a 2-d array... is there any other way to do this?

Why can't it? You know the length of your input value (.- is 2, -.-- is 4). So look for a match that matches both characters and length. (.-- and .-.- would be rejected for .- because neither are two characters.

Error checking? :: my thought on this is that i should pass the entered string to a new function which loops through the string, filtering out errors... however. i do not know how to start coding this function.

This depends on how you define error. Since we don't know your definition, can't help.

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

Do you know arrays?

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

C'mon, guys. Stop telling him it's impossible!

Yes its impossible for a newbe.

My point is stop telling him it's impossible. Explain what he need to know to do it so he can start looking into the functionality. He can then tell that he's not ready yet.

There are ways to say no without dashing all hope... :icon_wink:

Ancient Dragon commented: good point :) +21
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

C'mon, guys. Stop telling him it's impossible!

Ben, since you are new, you need a more detailed plan.
#1) How do you envision access to the music. Files on disk? Streams off web?
#1a) If files, for you know how to navigate a disk?
#1b) If streams, do you know how to connect to one?
#2) What formats are you going to support? Wav, MP3, Ogg, etc?
#3) What do you know about playing sound from C++?
#4) What do you know about reading music files/streams in C++?
#5) Console or GUI? I assume GUI. What have you done so far that's GUI-based?

These are just some basic questions you need to be able to answer... and program.

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

Hello,
I'm tring to read a text file and pull pieces of the line into separate functions.
I can open and close the file in the main. When I use the getline() it reads the whole line, I only want to read up to a certain point using strings instead of c-strings.

Why? And how far?

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

Dear salem ;
the first " Thank you "
but
sorry salem this must be submit

"
phase1(due 25/11/07), you are required to submit the initial user interface and the UML notation [using Rational rose ] of basic classes
"

and ... etc

plezz help me

I don't understand. Because it is due 25/11/07 you are unable to:

The programmer (ie YOU) had better start with the reading of the forum rules, and putting forth some demonstration of effort which is more than simply copy/pasting the assignment with a horrid colour scheme.

Is this correct? If so, think again. Rules are rules and you need to do what they say if we have any chance of helping you. As it is we are unable to help because you didn't give us anything we can help with.

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

By the way, you should have posted this in the C forum. There is nothing specific to C++ in this thread.

There's nothing specific to C either. Other than he's writing a C++ program.

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

He doesn't. He just want attention by posting lame questions that are mostly unintelligible. He probably has refused to read The Rules and other helpful posts to aid in asking good, well formatted questions..

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

"User-specified" means you must be able to read "command line arguments" and convert the arguments to integers.

The program will be run with a command similar to: progname lowval highval Then in the code grab lowval & highval (which will be c-strings) and use them.

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

Good grief, nobody would ever use the same computer for ten years! One exception, maybe the government does for flight control.

Nobody? You don't know the people I know...

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

Still having problems, and the culprit is definelty the string.erase modifier.
Does this modifier have to be called by reference ( I mean by a pointer to a string) and the other statements like newstr do that by default?
Is that the problem?

At the moment
newstr.erase(j) // j=8
wipes the whole string.

Maybe you should look up how string.erase works. This took me 30 seconds to find rather than the two hours you've been posting.

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

What happens is that the getline gets the information from the previous cin.
so say I cin hello world hello world,
my cout will give me world~10hello~10world+garbage.
any reasons why?

There is no previous cin so we can't tell. We also don't know whether SA is a c-string, C++string, integer, or something else.

Without details, help can be pretty unuseful.

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

Depends on the reason. If you want to play it, read it with an .avi player, like Windows Media Player.

If you want to look at the totally unreadable contents (except the header), open it as a binary file and read it as bytes.

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

So I guess it's somehow my problem?

No necessarily yours. It's probably Opera's.