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

Just saw it tonight. If the crust shifts 23 deg and brings China close enough that the plane can land without getting wet, why were the mountains untouched? Seems to me the shift would cause massive destruction there, too.

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

I just realize you have it static. Of course it wouldn't work.

You do not want your variable to be [B]static[/B] .

Your code:

static int lowest_num;
  static int  next_num;

Do you listen this well in class too?

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

My password is always the day of the week my password was created. I tell people that, too, because it's not like they'll know what day of the week I created it. That makes it secure. Extremely secure.

Really? Give me 7 guesses... :icon_rolleyes:

Nick Evan commented: hehe +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You do not want your variable to be static .

Set lowest_int to the first value in the parameter list, then check all the others.

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

I showed you how it works for hh:mm:ss from seconds.
Your task is to do weeks, days, hours from hours.
It's the same procedure with different numbers. How many hours in a day? How many hours in a week?

Simple as that.

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

Take for example you want to convert 7520 seconds into hh:mm:ss. Use integer math
To get hours: hr = sec/(60*60); // int math truncates What's left is: sec = sec - (hr*(60*60)); // remove the #hrs Or using mod: sec = sec % (60*60)); // gives remainder if hrs divided out From here you should be able to do minutes, then figure out how to do your project. It's the same.

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

I suppose you're right. What I mean -- now that you've lambasted me :icon_wink: is that sonce the functionality requires nonstandard techniques, without knowing what the instructor had in mind (taught) we will very possibly come up with a solution that either cannot be done with the compiler in use or is too advanced and uses functions that are unacceptable to the instructor. IOW, we haven't enough information to suggest a nonstandard implementation. ne?

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

In standard C++ you can't. If your compiler is one of those that has enhancements, there may be a way, but it's non-standard and therefore not recommended.

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

Not in standard C nor C++. It requires functions that are not part of the language, but some systems and compilers have enhancements that could allow it.

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

Can you hide the CANCEL button? If so, process Cancel code using the OK button.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
cout << square << endl;

That's because you printed the value of square . You didn't actually call the function.

Look up calling a function in your text.

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

When you test each character do you really want to use i to save the result?

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

Being a human and not a computer, it helps to give details. What is input? What should be output? What is actually output?

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

To compare a character value, use the character. Single quotes around a single character is what you need: if (chr == 'y') And remember, 'Y' and 'y' are not the same values...

For comparison, double quotes go around a string (or multiple characters): "This is a string"

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

If there aren't any questions relating to the subject, it would be useless to add a forum. But if there are a lot of questions on the subject in an appropriate/related forum, then it makes sense.

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

size_t is a data type, not a data size. int is a data type. char is a data type. So is size_t. What goes into it is the result of executing the sizeof() 'function' -- it returns a data type of size_t.

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

Every time you type a character in at scanf("%c",); , do you hit an ENTER? Where does that second character go? It gets read with the next scanf() . See this series about why you should not use scanf() for character & string input. Use fgets() instead.

And in your case, you can define a string instead of a single character, use fgets() to read the input (which automatically clears the input buffer -- within reason), and simply look at the first character in the string for your character. Yes, it's a little kludgy, but that's the problem with keyboard input in C unfortunately.

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

Right away you shouldn't use:

char name[20];
scanf("%s",&name);

It should be:

char name[20];
scanf("%s",name);

Actually, no it shouldn't. See this.

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

Display each grid you generate and see where the errors occur in the generations.

Are you taking into account that the edged of the grid only have 5 neighbors and not 8?

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

Since you are using upperCase and lowerCase as character arrays rather than strings, you need to output each value individually.

If you want to use them as a string, you need to remember that as string always ends with \0, so they need to 27 characters long.

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

Wouldn't it be helpful to us that aren't psychic to actually explain the problem? I assume you are having trouble compiling.

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

how can we use a printf statement without a semicolon???
this was a question asked during an interview of a computer engineering student.

Assuming this was a job interview, I suggest you stay away from any job that asks foolish questions like this. I would not want to work for a company that want it's programmers to use tricks that make code unreadable.

yellowSnow commented: First sensible response to this thread. Exactly what I wanted to say. ;-) +2
kvprajapati commented: Very good suggestion. +6
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Let's see...
No CODE tags, even thought there are at least 6 places they are explained, and 3 of them on the main page alone.
No explanation about why code was posted
I guess all there is to say is:
Congrats for writing some code! What's next?

yellowSnow commented: Persistance against a never ending wad of crap posts. +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Look into the modulus (%) operator.

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

Learn to Format your code. That generally solves every bracket problem immediately.

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

weird is not an approved IT term. Be specific. Give details. What is the first question your mechanic would ask if you told him "my car is acting weird?"

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

I am too new to c programming.I think as the program doesnt return any value you should either put void main,

NEVER use void main()

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

You have a ; you don't want at the end of the while statement:

while ((c = getchar())!=EOF);
      if(islower(c)){
      	++letter[c-'a'];}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Code tags explained:
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used, even in responses to your posts
6) Even on the background of the box you actually typed your message in!

Somewhere in those places you should become a CODE TAG expert.

"The array element that corresponds with
that character's ASCII value is incremented by one ...

You have an array of 128 items (call it charList ), each one corresponds to one character in the ASCII chart. The array element (a character from the input array) is used as an index into charList and that entry is incremented. That character is now counted.

... along with a counter called textLength that tracks the number of entered characters.

textLength is incremented for each and every character and counts the total number of characters entered.

The frequency table [charList] , headers [?] , textLength, and the percentage of all the characters printed.

I think you missed something here.

Then a "for" loop incremented by the 128 elements in the standard ASCII table uses a condition to check if the value of the …

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

There is no standard way to read characters like getch()

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

Another option is: cout << "." << flush();

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

How to freed allocated memory?

delete []p;

Don't you also have to delete each p array? :icon_wink:

If you aren't sure, the answer is yes, delete each array first before deleting p itself.

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

Enough, people. The facts are
1) fixed code should not have been posted by anyone other than the OP
2) fixed code should not have been improved by anyone unless the OP posted correct code in the first place.
3) People who expect the world to give them a free ride deserve the right to fail, and do not deserve the right to pass.

Now stop the flaming and get back on track.

tux4life commented: Finally! +11
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I never posted a problem in my life so I prob encased this code wrong too.

you did much better than 95% of the new posters that can't be bothered to understand the forum before posting. :)

1) How can I make a new line within my "output" file after six values are written?

Simply output a newline after the six values - \n

2) What would be the best way to convert these values to binary before I writ to bin output?

Not sure what you mean -- based on the input you gave. If all you want is to break the 139 into binary, use the the && operator to test the last bit of the number, and >> to shift the second to last bit into the last bit position. Repeat until done.

Question for you:
What are the digits and tabs after the number in the input for? What do they mean?

Also, read this about using feof(). You're not using it properly.

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

Here's what I have so far.

And are you still having problems? Are we supposed to use our psychic powers or would you like to explain fully what the problems are now?

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

Your 1st half of the array array[x][0] is never initialized to zero so the values start out with garbage.

tux4life commented: Yes, that's the solution :) +10
Hiroshe commented: thanks +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I am always ready to answer your question, but not until you get a modern compiler that isnt gimped

Then stop replying posts you have no intention of of adding constructive responses to!

Adatapost, you do not have to use a jephthah-approved compiler.

kvprajapati commented: Thanks +5
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Load 19 random values. If a 0 is generated during these 19 values, remember that fact.

For the 20th value, if a 0 was not generated, load a 0, otherwise get one more random number.

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

I've said this already, and I'll say this again: I still think requiring X number of posts before a user can add a signature would work wonders to stopping this crap.

But for some reason higher-ups disagree with me. *shrugs*

So do I. For people like Jen0608 with 170+ posts, it's easy to make the required number of posts in one sitting to get to the sig limit.

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

Consider this loop:

for (i = 0; i < 5000; i++)
{
    sprintf(ifile, "file%04d.dat", i);
    sprintf(ofile, "output%04d.dat", i);
        //process the files
}

Look up the pieces of this code to understand what is happening.

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

Actually, FC did not bump a really old thead. NetworkExpert did. He just tried to help out what he saw was a current thread.

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

>i hope i did tag right on code posted.
Alas, correct tags are:
[code=cplusplus] source

[/code]

But you did get the CODE tags correct. The cplusplus part is optional.

Also, the PREVIEW button would show you if the tags are correct.

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

How would i clear the buffer? Can i use the call cin.ignore('/n')?

Did you try it? What happened?

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

You don't care about the girls? :icon_smile:

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

First thing you need to do is rethink the YEAR loop. Make it shorter. The leap year section in it makes the loop too complicated, and it's wrong. Don't deal with LY as a full year, it's one day.

Start with that.

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

You didn't tell us the most important thing about your program. What is happening to make you think it's weird?

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

If you are asking about ways you can improve it, if you look at itoa, it needs to be able to handle negative numbers and it needs to be able to handle different bases:

char *  itoa ( int value, char * str, int base );

Agree with negative, disagree with base. Since it is a compiler-specific function, there is no 'official' definition. Therefore, adding base is simply a possible feature/addition. :icon_wink:

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

When you finish reading a line, you are automatically ready to read the next line. So just start reading again and there you are!

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

Read the rest of the current line.

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

Green adds points to reputation.
Red subtracts.
Grey, no change to rep points. It's because the person that gives rep doesn't have enough posts that actually affect someone's rep.