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

As I said, a char is just another number that outputs as a letter.

char xchar;
cout << "Type a character:" << endl;
cin >> xchar;
xchar = xchar + 3;
cout << "The character is now " << xchar << endl;
cout << "It's new value is " << int(xchar) << endl;  // display the number value
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Simply add one.

A char is simply a number output in a special way. B is the value 66, C is 67.

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

I didn't understand why for(...) at the beginning, a has to be 0.

Who says it has to be 0? Test it. First thing in the program just print out the array.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
const int DAYS = 7;
const int TEMPS = 2;

for (int days = 0; days < 7; days ++)
{
    cout << "Enter High Temp for day " 
         <<  days + 1 << ": ";
    cin >> xTemps[DAYS][TEMPS];    // This always loads xTemps[7][2] --
                                   // which does not exist.  Max is 
                                   // xTemps[6][1]

    cout << "Enter Low Temp for day "
         <<  days + 1 << ": ";
    cin >> xTemps[DAYS][TEMPS];    // Overwrites the above.
		  //end for
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You already check to see if the word has 3-6 characters. Also check for an ' too before inserting the word.

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

Who's teaching these people computer lingo????

My program runs a three dimensional maze (3x3x3 = 27 locations)...

No, it creates a maze. It doesn't run anything.

... the start and exit rooms show up on the run compiled program ...

A "run compiled program?" What the heck does that mean? Run from the IDE?

... but the code room does not cout?

Things don't cout. Things get displayed. A ? is used after a question, not a statement.

However if run from the executable created it shows all three rooms, re-running of the compiled...

The executable created is the compiled...

It compiles fine apart from this ...

It compiles fine because you have no syntax errors. Logic errors do not affect compiling in any way.

... and I am not sure if somehow I've coded it wrong, although then it should have thrown up compile errors?

If it doesn't do what you wanted, you coded it wrong. If you write your code wrong, how is the compiler supposed to know that? If your code is cout << "Yellow Woild" << endl; , do you expect a compiler error because you misspelled Hello World?

do {
   time_t now;
   time(&now);
   srand(now);

srand() and all this time stuff should be at the top of the program, not in the loop. All you are doing here is resetting the random generator to the same value, which generates the same random values each time the loop runs. …

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

Then you did it wrong. Are you really asking us to write it for you? We can't help you fix it if we can't see what you did wrong.

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

First, after entering the number, calculate the number of days.
With what's left after removing the number of days from the number, calculate the number of hours.
Keep going until you get the seconds.

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

You can't use .eof() in this manner. You don't hit EOF until you actually try to read past end, not when you read the last character. Therefore, you will go through your loop the final time after reading bogus data.

Read the first characters before the loop. Then read the next characters at the end of the loop.

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

You never load result with anything. At the end of inttobin() you've loaded buffer, then output result. But you didn't move buffer into result.

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

Ok so the program compiles fine, but when I actually run it, it is not printing out the result of intobin(hextoint(st))

So finish formatting your code properly and post it. We can't do anything if we can't see the current code. And please explain in detail what's wrong, not just it won't print.

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

Better use short or short int for age variable since this has the least range other data type.

Shorter than char? I don't think so...

Use cin to read the age variable.

You realize this is the C forum, right? That code can't possibly help.

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

You have to specify a value, not a variable, when defining an array:

double x[16][2];
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

A lookup table is a list of values. You define the array and it's values at compile time:

float sinLookup[] = { val1, val2, val3, ... };

Each entry corresponds to one angle you want available.

Get the angle, use it as an index into the array to get the sine. Of course you need to figure out how to take the angle and convert it into an integer index. That's the main task.

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

Because it's simply a pointer to a single char, there is not sufficient memory allocated where that char is stored to hold an array of char.

Actually, there isn't even a single char. It's just a pointer to nowhere in particular.

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

And keep in mind 5/9 = 0. That's integer arithmetic. You want 5.0/9.0 to get the correct answers.

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

I have no idea what newToCheck is for.

Line 8 defines it as a char pointer. No size so there's no storage.
Line 29 seems to serve no purpose at all.
Line 31 uses newToCheck[n] but the location has no storage space, so even if you tried to run the program you'll probably crash.

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

1/1! is not 0, it's 1. Do the math -- what is 1!?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
for (int a=0; a<size; a++) 
        for (int b=size-1; b>=a; b--) {
            if(set[b-1] < set[b]) {

                temp=set[b-1];

What happens to temp when b == a in this loop structure?

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

It all depends on what line 36 looks like with your change.

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

Since I can't read your screen from here, maybe you could post what you tried and show us what happened. Can't help without knowing.

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

I don't speak alien language. Also, without knowing what went wrong (you didn't explain the problem at all) what can we say?

Maybe you should try reading one field and see if that works. If it does, read one more field. Keep adding until one full line is read.

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

Strings and character arrays cannot be typecast as values. They can only be converted. Look up string to number conversion techniques.

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

Look at kbhit() . With that, getch() , and a timer you can do what you need.

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

Please read this about fflush() And read this about gets() We also recommend you not use the system() call to clear the screen. It's annoying to the users and it's also not standard.

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

Do you know structures yet?

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

So what's happening now? If you need help, you have to describe in detail what you need help with.

Just curious, why are you using '_' before each structure name?

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

First, your open is fine. Adak, he's using argv to open the data file.
Second, sree_ec is correct.
Third, when you use fgets() to read 2 characters, the array must be of size 3. Remember (or look it up), fgets() always adds an ending \0 and reads length-1 characters.

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

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

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

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

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

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

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

Never -- NEVER -- NEVER call main() to return from a function!!! Never!!

Modularize your program. Create subroutines that do a single part of the task and call them, like
1) Generate the list of numbers
2) Read the list
3) Test for palindrome
etc.

Then you can work in short sections at a time.
As for your sort problem, I see nothing that sorts at all. Nor can I see a reason to sort.

Also, for the sanity of your user, get rid of all the system("cls"); commands...
And the system("pause"); commands -- see this

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

Absolutely. Come up with an idea and we'll help you fine tune it.

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

First thing I'd do is create a function that simply outputs a board and call that instead of hard coding it in other functions.

Then, add output statements to follow your program (or use the debugger) to see where the problem shows up.

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

What do the numbers tell me, in terms of frequency, amplitude and maybe time?

Thank you muchly!
drue

Pretty much everything.

If you are really asking "What is the format of a file", you'll have to search the web for for a definition of the file format.

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

First of all, you read two numbers and never read any more.

Try this:
Read the first number. Set min and max to this number. This seeds the min/max with at least one number actually in the list.
Set up a loop to read the rest of the numbers one at a time and test for min and max.

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


Can i further improve it in any way?

Thanks.

Yes. See the comments I added:

void trimString()
{
	char s1[] = "hello world";
	char s2[] = "el";
	int i, j;

	/* Do not use strlen() as a loop parameter.  
	   Use it to load a variable before the loop and use 
	   the variable in the loop definition */
	/* Why are you casting the value to signed? Define the loop 
	   parameter variables as unsigned if you think it's necessary */
	for (i = 0; i < (signed)strlen(s1); i++) {
		for (j = 0; j < (signed)strlen(s2); j++) {
			if (s1[i] == s2[j]) {
				s1[i] = -1;   // this is good
				break;
			}
		}
	}
	for (i = 0, j = 0; i < (signed)strlen(s1); i++) {
		if (s1[i] != -1) {
			s1[j] = s1[i];
			j++;
		}
	}
	s1[j] = '\0';
	printf("\nString is%s", s1);
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I posted my code an hour ago too so how do you know what I have changed and what not.

Then why are you asking for more help if you aren't telling us the current state of the program? Aren't you asking us to shoot a moving target -- while blindfolded?

Listen to the Dragon. He's trying to help using the definition of the problem as you stated it. super-sonic is changing the definition of the problem because he does not understand or didn't read your requirements.

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

cin.ignore has absolutely nothing to do with cout. Nothing. It has to do with cin.
When you input a number using cin, you hit a RETURN to allow the number to be read. But the RETURN is left in the input buffer to be read on the next input -- like getline(). That RETURN is now read and the getline() continues as defined. That's why the cin.ignore is used.

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

If you do that, Word won't be able to read the document.

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

So move the initialization code where you need it to be.

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

Define "goes nuts". That is hard to imagine.

Explaining a problem correctly often results in more accurate answers and better help.

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

and I assume that involves malloc or calloc, where is a good site to relearn those key concepts again?

No, it involves creating space: char answer[20]; Also, see this series on scanf(). You are using it dangerously.

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

I don't see a loop... I see a question. Read the member rules -- especially the Keep it Clear section.

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

Use an array for the 4 cards. Get a random number from 0-3. This will be an index into that array to point to the win card.