Function calls cause overhead, local jumps do not. However, function calls are used most often and people can read them easier; and as quzah said there can be problems with debuging. It's really all...
Type: Posts; User: *pointer
Function calls cause overhead, local jumps do not. However, function calls are used most often and people can read them easier; and as quzah said there can be problems with debuging. It's really all...
I found two problems, the infinite loop was caused by the inner most loop. It was using the same counter as the loop before it and one was multiplying while the other was dividing which kept the...
Heh, no one would use goto in that situation at all. Notice that the functions do nothing as well, I was trying to save space by making it sort of like a fill in the blank.
What kind of problems...
Try using a long double.
Though I've never used it and don't know if it's compiler specific or not, I believe there is an asm keyword that allows you to put assembler right into your program.
int main( void ) {
asm...
After you use the value from getch, call cin.ignore(). That will clear the input stream buffer so that you can read another value.
The only people I've heard say never to use goto are the ones who don't understand it properly, they're just saying to others what was told to them. Yes, goto can cause difficult to follow code, but...
>Truthfully, all file read functions eventually call fread().
Okay, then if I wanted to could I use fread to get all of my data? I thought fread was only for binary files, which is why I've never...
I don't know what you people are talking about, quzah always answers your questions in a knowledgeable way. His attitude in doing so doesn't matter as long as you get the information that you ask...
if((isalpha(input)) == TRUE){
/*code to handle a letter*/
}else{
/*code for proper input*/
}
This one
Okay, I see what you mean by a division by 0. What was causing this was the initialization of number_of_students to 0. Also, you never changed this in your code so it stayed at 0 and the final...
Bit twiddling hurts portability, unless you plan to use the program only on your own computer it's really best to use the 'one size fits all' functions. Though knowing how to play with bits is nice...
That's an easy one, read the input however the user types it in and then parse the string to be all upper or lower case.
int main(void){
char pWord[SIZE];
pWord = cin.getline();...
You had a bunch of errors in there, 19 to be exact from the start. So I cleaned up the code a bit and fixed the errors, as well as added some much needed formatting ;)
Look at what you had before...
Try this, instead of using a counter you use two reader variables, one to read the actual variable and one to test the next one and see if it's valid for the operation. Each time you read the whisker...
char c = 'a';
toupper(c);
cout<<c<<endl;
That should print A to the screen, not a. Be sure to include ctype.h
Just so you know, enclose all your code on this board in the code tags for easier reading. To answer your question, here's the updated code, look for where I put the statement in the while loop. It's...
Hmm, I believe my first program that was not a school project was a text based RPG battle engine. I think it was pretty fun, you gained levels, developed new attacks, and there were a bunch of...
You mean how do you reset a variable so that the next iteration of the loop doesn't use the current value? try this:
baz = 0;
for(i = 0; i < FOO; i++){
for(j = 0; j < BAR; j++){
...
Do you have anything yet? At least try to do it on your own and if you can't, then ask for help.
//Read one character at a time and print it out.
#include <iostream.h>
#include <stdio.h> //required for use of getchar()
int main(void){
int c;
cout<<"Enter ctrl+z to quit"<<endl;
...
The easiest way to pause a program is getchar(); Like so:
.
.
.
while(1){
cout<<"Something"<<endl;
getchar();
}
You can read all you want, but you still won't know jack until you actually try and use it. Believe me when I say that actually writing programs opens the doors of understanding.
You want to format a float into currency?
printf("$%.2f", foo);