Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

First, you have to extract the individual digits from the original value of b so that they can be added together. Do that in a loop using the mod operator % to extract the right-most digit then divide by 10 to shift all digits right

int x = 0;
int b = 01234;

x += b % 10; // get right-most digit and save in x
b /= 10; // truncate right-most digit

once you get that working for both b and h come back and we'll work on the rest of the problem (unless of course you can do it yourself)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

instead of getline() you could use the >> extract operator

string name;
int number;
int line_count = 0;
while( myfile >> name >> number && line_count < x)
{
    ++line_count
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>so I've assumed it's all C's fault.
Never make that assumption because you will ALWAYS be wrong.

>>path->points[length] = (struct pf_point32*)pf_allocate(sizeof(struct pf_point32));
function pf_plot32()
That is trashing memory because points is a pointer array of unspecified length


I am supprised that you have coded all that but have never been told to NEVER EVER put executable code in header files. If you need to put executable code in a file other then the main program *.c file then create another *.c file, compile the two separetely and link them both together at the end. How to do that depends on the compiler you are using because they all do it differently.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

getchar uses round parentheses not square brackets to hold the parameters.

you don't need the & address operator on line 26 because arrays are ALWAYS passed by address.

line 28 has a couple problems: if you only want one character then use "%c" instead of "%s". and it has the same problem as above on line 26.

line 31: The double quote immediately after '%c should be a single quote. The rest of the errors will be fixed too when you correct that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The formatting is simply awful! If you reformat in more readible style and repost people may help you faster. Also do not use color tags -- use code tags and DaniWeb will add correct colors.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you can use modf to split a double into its two parts

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 1 is wrong -- eof() doesn't work the way you think it does. Here's the correction (combin line 1 and 3)

while ( getline(potter, text) ){

The getline() function does not put the '\n' in the input buffer, so the test on line 30 will never ever be true. The solution is to just display '\n' after that loop terminated.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

where did you look for the *.exe file? The compiler will put it in either the debug or release directory, depending on how you compiled it.

If that did not solve your problem then delete both the debug and release directories then the precompiled file, zip up the rest and attach it to your post here.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I will read the sectors using INT13 BIOS and the disk already has a FAT file system.

that won't work for huge hard drive partitions -- those larger than about 2 gig.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Ideas??
Yes. You have to create a project first. File --> New --> Project Tab --> Win32 Console Application (if that is the kind of application you want)

>>Does anybody know where i get the programm borland c++
Probably from www.borland.com

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There is no reason why we can't ship nuclear wastes to the sun for safe destruction. Yes it will cost a lot, but probably cheaper than trying to safely store it here on earth for thousands of years.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

OMG [sarcasm]You all are just jealous that you didn't get the Nobel Peace Price like Al Gore did the other day :) [/sarcasm]

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

can't help you without the code because I can't see your monitor from my chair.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Unbelievable. 75 posts and you still don't know how to format your code ! I certainly hope you do not plan to turn in that to your instructor.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I wish I had a virtual hand that would reach out and just slap the hell out of anyone who makes a post like this :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well, I compiled with VC++ 2005 Express and get one warning

'deleteCell' : recursive on all control paths, function will cause runtime stack overflow

You need to fix that because if that function is called it will crash your program.

[edit]
move gets set to true at line 118, which means the test at line 126 is never true.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Another suggestion: don't hard-code the array dimensions all over the place like that. If you ever have to change it chances are pretty good that you will make a mistake somewhere and it will require a considerable amount of debugging.

The solution to that problem is to define const integers at the top of the program then use those constants whenever needed. That way there is only one place in the program to change the array dimensions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

for starters, move lines 27-33 down after everything has been calculated. You can't print the values of the variables before the calculations have been completed.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>That doesn't work either
why do you say it doesn't work??? Looks ok to me.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Thanx for your answer.
Now suppose I've a pointer of ifstream. Is there are any way to get the timestamp of that file from that pointer?

The stat() function does not require an open file and is compatible for every standard compliant C and C++ compiler.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The total variables have to be declared outside the loop so that they don't get re-initialized on every loop iteration.

>>It doesn't work
Then you didn't do it right. In the example I posted, grossPay is the gross pay for the current line in the file. Gross pay is not included in the file -- you have to calculate it based on other information in the file

Gross = hours worked times hourly rate plus overtime hours time hourly rate times 1 ½

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1. remove the semicolon at the end of line 32

2. remove the extraneous braces on line 53 and 55

3. main() is missing a closing brace somewhere. Use your spacebar to align the blocks of code better so you can easily see where the braces should be.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use the stat() or fstat() standard C library functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you are supposed to be summing up the total amounts, not counting how many there are. For example Total Gross Pay is:

grossPay = ???
totalgross += grossPay;

>>and that would go inside the while loop?
Yes because those calculations have to be done for each line in the file

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>How can i get the following:
Looks simple enough -- just add more variables to hold the those totals and add them up while reading the file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

chooseNumber() only permits the player to enter a value between 1 and 9. Yet the matrix is 15x12. Why the difference ? 1 and 9 are the values in the cells, not the matrix size.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You could handle it by dynamically allocating the buffer size and using another buffer that doesn't change size to read the initial 4 bytes, something like this:

char buf[4];
char * buffer = 0;

while( fileopen.read(buf, 4) )
{
     fileopen.read( &temp_len, sizeof(temp_len) );
     if( temp_len < 1)
     {
            cout << "error\n";
            break;
      }
      buffer = new char[temp_len+1];
      fileopen.read(buffer,temp_len);
      // now do something with the buffer contents
      delete[] buffer;
      buffer = 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

NASA predicts that the Sun will also reverse its own magnetic poles during 2012 as result of reaching the end of the current 11-year sunspot cycle.[12]

Above from Wikipedia.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Agree -- vmaes has a lot better solution. :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why can't you start the program ? what errors do you get? were there any errors or warnings when you compiled it ? did you fix ALL warnings ?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you have defined two variables with the same name -- seats, one is a parameter and the other a local variable. My guess is that you ignored your compiler's warning about that. NEVER ignore warnings because most of them are errors.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

rename the parameter to something else other than Average. There is no point to that parameter anyway, just make it a local variable and get rid of that parameter.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you have to initialize year to EOF before line 12 then add an if statement after eof to see if it still the same. The problem with this is that year will not be changed if you type anything other than numeric digits.

do{
cout << "Enter a year: ";
year = EOF;
cin >> year;
if( year == EOF)
    break;
// rest of program here
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

_alloca_probe is probably being called from one of the library functions you call. That happens a lot.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In 2038 or 2106 (depending on signing) most UNIX/Linux and modern Windows NT based systems will fail due to a date bug. This could very well signal the end of the world, or just anothe fun time for y2k paranoids

Not true any more with modern compilers because that problem has been fixed for another hundred years or so. Old compilers like the original Turbo C and all programs produced with them will be trashed.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 126: you did not specify the parameters are passed by reference -- you have to use the & operator to do that

double ComputeHourlyPay(double hoursWorked, double hourlyRate, double& regularPay, double& overtimePay, double& totalPay)
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

each os is in its own partition. use a fdisk utility program to delete all those partitions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes that is indeed a huge pain in the ass! And no I don't know if there is anything we can do to prevent it other than being very very careful what we do.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

because ProcessOfficeWorker() knows nothing about the values of variables set by ComputeHourlyPay(). You need to pass more parameters to ComputeHourlyPay() by reference.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you don't need the recursion. First compute the normal pay. Then if over 40 hours compute overtime pay. Here OVERTIME_SCALE would have to be redefined as 0.5

double ComputeHourlyPay(double hoursWorked, double hourlyRate)
{
	double regularPay = 0;
	double overtimePay = 0;
	double totalPay;

	cout << fixed 
		 << setprecision(2);
		
	regularPay = hoursWorked * hourlyRate;
	if(hoursWorked > 40)
	{
  	    overtimePay = (hoursWorked - 40) *  (hourlyRate * OVERTIME_SCALE);
	}
	totalPay = regularPay + overtimePay;
	return (totalPay);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you are unmarried and/or have no children to support then you don't need credit cards. But if you live in USA you will eventually join in the Great American Dream and get up to your eyeballs in debt. Almost nobody lives in this country debt-free and credit-card-free.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Well you don't really want to flatten a post
I didn't notice the misspelling :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Unless you know who took it or know someone else who saw the thief then there is probably very little you can do about it other than turn it in to police. Chances are you will never see that laptop again.

>>can there be any way to trace it if the person goes online using it.
no.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Depends on the operating system. MS-Windows/MS-DOS (and probably *nix) if you don't specify otherwise the file will go in the current working directory where the program was started. If you use MS-Windows use Windows Explorer to search your program's source code directory and you will probably find it there. Or use the search feature to locate it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> am a newbie to the C++ arena
attempting to write a windows program is NOT a good way to learn c++ language because it is too advanced. Start with something a lot simpler and work your way up from there.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I'm not sure if this is the place...
you should have used the Flat Bad Post link that is on the same line as the post's time. That will get the attention of appropriate mods a lot faster than posting iit here.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you mean you want to concantinate all those words into one big comma-separated string? Not too difficult to do if you use std::string c++ class

std::string the line;

while read a word is successful
   line += string;
   line += ", ";
end of while loop

now the line will have a trailing ", " which you will have to strip back off.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you have to rewind the file back to the beginning. Before doing the while loop search call dict.seekg(0); And move that line that says "word not found" outside that loop because if the program goes there it means that the word was found.

iamthwee commented: Nope, you don't have to use dict.seekg(0) to read the file again. -2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

ask whoever wrote your library how to use the functions, or look around for the documentation (hopefully it exists).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Hey..sum1 help how to psot some msgs. and questions here!1..Plz

why are you bumping a 2-year-old thread? And please spell out words so that everyone can understand you. I, for one, haven't the slightest idea what you posted.