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

You can display leading 0s like this (include <iomanip> header file cout << std::setfill('0') << std::setw(6) << b << '\n';

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

>>i am taking a class and have been asked to explain why this is bad
Beats me. If you find out please post the reason so we can all learn something.

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

add another variable to keep track of the element number and use it just like you do highTemp variable that appears on line 6 of the code you posted.

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

The last post was from someone named Brian Muth, and suggested opening the file with "rb+", which is what you want to do.

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

The last post in that thread told you how to write to the file without first deleting its contents.

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

compilers will leave holes in the structure if its data members are not aligned properly. One reason for adding padding members is to insure the structure compiles the same with every compiler and operating system and to make transmission across tcp/ip more reliable.

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

One of the purposes of MBA is to prepare you for supervisory roles, such as department head. MBA is not directly related to IT. You should take a look at your school's course requirements.

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

And many new ones have cell phones pre-installed and ready to go any time day or night.

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

Got to admit my system is getting pretty old too, but has been very reliable throught the years with few breakdowns and no hard drive crashes. If this one stops working permanently I'm not going to bother with a new one because it will take too much time to educate and train it the way I want.

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

LOL: Very similar to the one about upgrading from girlfriend to wife.

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

I suppose you could repeatedly call time() and exit the function when the desired amount of time has expired.

void foo()
{
   time_t t1, t2;
   t1 = t2 = time(); // starting time
   while( (t2 - t1) < 10 ) // 10 seconds
   {
       // do something
       t2 = time();
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The example you posted probably works because child class has no data members, just one method. When you allocate a class with new the compiler only allocates data because the methods are already in memory. If you add some data members to child class I'll bet the program won't work right when trying to access the data.

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

You must be talking about some sort of installation program, such as InstalShield because AFAIK Visual Studio has no such properties.

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

Mike: it took you over 33 minutes to press the Post Reply button??

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

I guess that sounds like some of those "the world is coming to an end" theories. Yes it will, but when is anyone's guess.

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

>> The <string> library has an "at" function which lets you check
Yes it does, but it is more convenient to just use the [] operator, and what about the tabs that may be in the string? Those have to be ignored too, which is why isspace() needs to be used.

int letterCounter = 0;
    for (int i = 0; i < text.length(); i++)
    {
        if (!isspace(text[i]))
        {
            letterCounter++;
        }
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I realize you are using CLR/C++, but here is a c++ program that works ok with floats.

#include <iostream>
#include <string>
#include "sqlite3.h"

// Delete this pragma if you are not using
// a Microsoft compiler.
#pragma warning(disable: 4996)

using std::cout;
using std::cin;
using std::string;

// Function prototypes
void fill(sqlite3* db, string tbname);
void CreateDatabase(sqlite3** db);
void CreateTable(sqlite3* db, string& tbname);
void display(sqlite3* db, string tbname);


// This is a callback function that is called by Sqlite to process the 
// resultset of a query.  There are other ways to do it without using
// a callback function, such this is the simplest to implemnent.
//
// Parameters are:
//      argc -- the number of rows in the resultset
//      argv[] -- the data for each row
//      azColName -- the name of each column
int callback(void *NotUsed, int argc, char **argv, char **azColName){
  int i;
  for(i=0; i<argc; i++){
    cout << azColName[i] 
          << " = ";
    if( argv[i] )
        cout << argv[i];
    else
        cout << "NULL";
     cout << "\n";
  }
  return 0;
}

// This function just display an error message that
// may have been returned by the various Sqlite functions.
void dsperr(char**db_err)
{
    if( *db_err )
    {
        cout << *db_err << "\n";
        sqlite3_free(*db_err); // release (free) memory
        *db_err = 0; // reinitialize the caller's pointer
    }
}

// This function is called from several places to get 
// the table name.  
void GetTablename(string& tbname)
{
    cout << "Enter the table name\n";
    cin >> tbname;
}


int main() …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
int
main(void)
{

When I was working on *nix and using vi I used to write code like that too, because vi can easily find any function by seaching for "^main". That's especially useful in long programs. But that was many many years ago, and IDEs have become smarter :)

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

Is there a question somewhere? Or do you just like posting code?

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

1>------ Build started: Project: test1, Configuration: Debug Win32 ------
1> test1.cpp
1>c:\dvlp\unmanaged\test1\test1.cpp(2): fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Notice the second line tells you what's wrong. Then if you removed the .h file extension your compiler should have given you these messages

1>------ Build started: Project: test1, Configuration: Debug Win32 ------
1>  test1.cpp
1>c:\dvlp\unmanaged\test1\test1.cpp(51): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(304) : see declaration of 'scanf'
1>c:\dvlp\unmanaged\test1\test1.cpp(55): warning C4996: 'getch': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details.
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\conio.h(128) : see declaration of 'getch'
1>  LINK : c:\dvlp\unmanaged\Debug\test1.exe not found or not built by the last incremental link; performing full link
1>  test1.vcxproj -> c:\dvlp\unmanaged\Debug\test1.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Is this a SQLite bug ??

No -- it is a bug in your program.

>>VALUES ('greyfurt', '"+Weight+"' , '"+arraySource_energy_kcal[0]+"' ) ";

Do not put quotes around the floats -- the quotes are only for the strings. You will have to format the query before sending it to SqLite, something like this

string cmd;
cmd = " INSERT INTO meyve(`category`,`weight`,`energy_kcal`) VALUES ('greyfurt',";
stringstream s;
s << Weight << "," << arraySource_energy_kcal[0];
cmd += s.str();
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

loop through the string and count the number of white spaces -- isspace() macro will tell you if it is a white space or not (white space is space, tabs and something backspace characters). Then subtract that from the total string length. Or just count everything except white space and you won't have to subtract anything.

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

Oh, I understand -- yes the link in my original post is pretty discusting.

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

When VISA is installed it most likely will add a registry entry in HKEY_CURRENT_USER\Software. Use regedit.exe on a computer that has it installed to verify the registry key. Then visually searth the entries in that key to find out if it has the install location. If not, then you are probably lout of luck. If found, then your program can easily read that registry key and do its one thing accordingly.

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

outraged about what? Slaughtering animals for human consumption is never pretty. There just is no nice way to kill something. But that doesn't mean we have to be cruel about it, as in a few utube videos I've seen. We in USA have laws against cruel treatment of animals, including those that are about to be slaughtered.

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

1. Yes
2, 3, and 4 -- I don't know
5. With a compiler. For MS-Windows you have several choices, such as Code::Blocks and VC++ 2010. For *nix normally compile with gcc, which is on most *nix computers. C programs have to be compiled for the operating system in which it will run, unlike scripting languages such as HTML.

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

For all you city folk this is a video of one way chickens are slaughtered on family farms. http://www.youtube.com/watch?feature=player_detailpage&v=lDtXeMHOMLw

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

I suppose it depends on where you live. That's probably true in many parts of the world, like China, where resources are scarce. But we here in USA don't have that problem -- yet. We can always increase meat production if needed.

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

>>I have a book here "Microsoft Visual C++.net" with all the installation and whatnot with it. It doesnt use the normal cin and cout but used Console::WriteLine and what not.

Because that is not c++ -- its a different language called clr/c++, which is a derivative of c++. If you want to learn c++ then create a win32 console application, not a CLR project.

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

>>im i to old
No -- I didn't start until I was in my early 40s.

Your situation is a tough one because you don't have a lot of spare time on your hands. Ideally, you might take a couple weeks vacation so that you can spend a lot of time learning how to program. But if you have small children that may even be difficult.

Don't worry about the math just yet because entry level programming doesn't normally require much. As long as you are familiar with basic algebra (add, subtract, multiply and divide) you should be just fine.

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

So how can I do that, please

Well, give it a shot and start to program. Start out simple -- first generate the list of random numbers. Only when you are finished with that -- and the program compiles correctly and tested -- should you begin the second part. The second part is to split the file into two smaller files.

We are not going to write the program for you -- just start writing, compiling and testing. You can always post the code you have written here is you come across a problem that you do not understand.

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

If the objects were instantiated in a header file and the header file included in two or more *.c or *.cpp files, then the linker would complain about duplicate declarations, not "redefinition of 'class player'". That's why its more likely a problem with missing header guards, or the class is in fact declared multiple times in the same header and/or *.cpp file. Even lack of header guards would not be a problem is the header file is included only once in the same *.cpp file.

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

There seems to be quite a bit of discussion about this topic, and it seems logical that with 32-bit IP addresses we would run out of them some time.

This is a topic I just came across -- if its old news then probably not something anyone would want to write an article about here at DaniWeb.

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

According to this article the internet will run out of IP addresses some time in 2011. Will the internet stop working then? Most likely not, its just that no new ip address can be assigned until IPv6, for "version six" is adopted, and will add more digits to the ip addressing scheme.

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

See this link. Scroll down a bit to the section "Converting from wchar_t * Example"

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

If you only have one text file, what is to be merged? There is no need to merge a list of only 512 numbers. Merge-sort is used when there are millions, or even billions, of numbers because they can't be all in memory at the same time.

But I suppose for academic purposes you could take a file that contains 512 numbers, split the file into two files, sort each file, then merge them. I a real-life situation you would probably have to split the original file into many snaller files. To split the file in half read the first 256 numbers, save them in a text file, then read the remaining numbers and save them in another file.

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

What is the error? Are you compiling for UNICODE or not? If UNICODE you can't just simply typecast CString.GetBuffer() into a char* because GetBuffer() will return wchar_t*, not char*. You will have to use one of the string conversion functions to convert it from wchar_t* to char*.

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

The function process() is all warong anyway. Go back to the requirements you posted and see how CFRS us syooised to be calculated. It is the sum of the individual double variables for only one student, not for four students. I think the function should be like this: It should return to the caller the letter grade and CFRS for just one student. The functdion should be called in a loop for each student

double process (Student a, char& letterGrade)
{

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

line 45 and 48: a, b, c, d and e are structures and you can not compare structures like that (unless you code in some operator overloads which I don't think you are ready to do yet). In the student structure which of the several double values are you trying to compare? You will have to fix this problem with something like this if( a.prelimExam < 0 || a.prelimExam > 100 || a.midtermExam < 0 || a.midtermExam > 100 || ...)

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

add function prototypes at the beginning of the program, before the first function in the *.cpp file but after includes.

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

LPTSTR is defined by Microsoft as char* or wchar_t* depending on whether you compile for UNICODE or not.

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

lines 30 and 32: You are still trying to invoke a function incorrectly. do not put the return type before the function name. If you want to call menu() then just say mainu(); -- not int menu() Remember: putting the return type before the function name makes it a function prototype, not a function call.

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

lines 160-163. The functions in those statements are NOT function calls, but function prototypes. If your intent is to call a function then remove the return type int, for example case 1:view_balance();break; Delete line 60 because it does nothing.

Now, where in all that code are you tring to put the two lines of code You posted in your original post that gave you the problems?

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

Or don't compile your code for UNICODE. Go to project --> Settings --> General and turn UNICODE off.

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

You will have to post the full code of the program you are attempting to write.

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

Did you read this (and the example at that link)?

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

you can move line 13 of the code I posted up above main(), but the other lines must be in a function.

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

The instructions are not clear enough. Do you have to generate two files that contain random numbers, such use a merge-sort altorithm to merge them into one sorted file? Or generate one large file, split it into two smaller files, then use merge-sort ?

You should start by reviewing these links

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

Might be a permissions problem. Does your program check the success of opening the files, such as with stream.is_open() ?