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

You could just simply do an insert then if it fails do an update.

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

>>Please don't do what AD suggested (sorry AD..)!
You are of course correct -- my sugestion only works in the very simplest cases with classes that do not contain pointers.

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

Just save them as you would any other objects. Say you have three classes

#include <fstream>
using std::ofstream;

class A
{
   // blabla

};

class B
{
   // blabla

};

class C
{
   // blabla

};

int main()
{
   A a;
   B b;
   C c;

   // now save the data
    ofstream file_ptr; // Declares a file pointer.
    file_ptr.open(“house.dat”, ios::out); // Creates the file.
    if (!file_ptr)
    { cout << “Error opening file.\n”; }
    else
    {
    // Rest of output commands go here.
       file_ptr.write(&a, sizeof(A));
       file_ptr.write(&b, sizeof(B));
       file_ptr.write(&c, sizeof(C));
          
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your program can create a file anywhere it wiches as long as it has the permissions needed to do that. You can't create a file in a directory where you don't have write permissions.

Or are you trying to ask if you can put the path in a file and read the path from that file. For example, if you have file named ./path that contains "/User/Joey/Desktop/". The answer is again yes, you can easily do that. Just read the file into a variable the use that variable in the call to fopen()

Joey_Brown commented: Gr8 guy !! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You are asking the wrong question. If you have an array of 100 structures then keep a counter to determine which elements have already been used. Its pretty simple concept -- really.

struct company
 {
    float east,north;
    char name[20],place[20];
 };

int main()
{
   struct company companies[100];
   int lastUsed = 0;
   
}

Another way to do this is to create a linked list of those structures so that the array can expand or contract as much as it needs to. Inserting into a linked list is more complex than inserting into unused spots of an array, but it has the advantage of not needing to know how may elements are needed when the program is compiled.

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

AFAIK SDL does not support console programs. See this if you have not already.

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

Funny, I've used Norton for quite a few years and have never had a problem with it (see below for an exception). Of course I don't visit sites or download files that may be infected with viruses. Even now I am running Norton 360 which includes antivirus, firewall, backup, disk optimizer and other utilities.

The only problem I have had with Norton Antivirus is when I was using VC++ 6.0 a few years ago -- Norton would sometimes not allow me to save source files, so I had to turn it off when programming.

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

there is no such thing as a syscall number. Linking assembly program to c library is the same as linking c-only programs. When you wrote a pure c program you don't call functions by some number but by a function name. Same with your assembly program. Just link with the appropriate c libraries and you are done.

Of course if you don't want to use the c libraries then your task is much more difficult. You will have to write all that code yourself. If you use the flat memory model and a 32-bit assembler then you can call win32 api functions instead of those 16-bit MS-DOS int instructions.

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

what are the errors with procs.asm??? Instead of using ml to link the two object files why don't you just call link.exe directly?

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

That '|' sign is called a cursor. If you want win32 api GUI program then there are cursor functions, such as GetCursorPosition()

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

I haven't tried it in c++ but can't you do it something like you would in a stored procedure?

if exists(select * from table where name = "John Doe") update table ... else insert table ...

I know the above works with Sybase database stored procedures. Since each databases has its own flavor of SQL you will have to test that to see of MS-Accesses recognises that exists keyword.

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

at line 4, Found and Temp both point to the same string. Therefore the parameters to strstr() on line 6 are the same string. And line 9 will do nothing because Temp - Found is the same as Dest - Dest, which is 0.

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

The only want to close MessageBox is to hit its Ok button.

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

Here is explaination of Document View archeture.

The difference without Document/View is that the MFC project does not contain a CDocument-derived class. All the data objects will have to be contained within the CView or some other class.

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

You mean you want to enter a date -- in that case none of the functions in time.h will help with that. Just call getline() and do all date validations youself (there are no functions that will do it for you.)

#include <string>
#include <iostream>
using std::string;
using std::cin;
using std::cout;

int main()
{
   string date;
   cout << "Enter a date\n";
   getline(cin,date);
   // now validate the date is in correct format
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Program archive will most likely have to make two passes through each of the command line arguments. The first pass will collect a list of file names so that it can build a list of of those names along with their file sizes. Once all that information has been collected store it as the header in the result output file. After thant make a second pass through the arguments but this time actually load each of the files and copy them to the output file.

You will want to read the input files and write the output file in binary mode instead of text mode so that the output file can contain any mixture of text and binary files.

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

okay.. I get vaguely all the points you guys said... Now if have to get a date, what should i use???

struct tm contains both the date and the time. See my first post of example how to get that structure for current system date and time.

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

The parameter to time() is a pointer to a time_t object, or NULL. Since NULL is often declareed as 0 you can call time() is one of three ways

time_t now;

time(&now);
// or
now = time(NULL);
// or
now = time(0);

Any of the above three are acceptable.

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

You have to move all those variable declarations from main() to getline() function.

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

post your program, and don't forget to put it in code tags

[code]

// your code goes here

[/code]

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

You are going to have to ask a better question then that. What exactly do you mean by "timer code" ??? Here is one interpretation.

#include <time.h>

int main()
{
   time_t now = time(0);

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

you formatted the fopen() incorrectly. Do not put s in quotes fp = fopen(s,"w");

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

Do the MFC Scribble tutorial and it will give you a rough idea how do do it. Basically you will have to learn drag-and-drop then create objects that draw themselves at given coordinates. To delete an object just have it redraw itself with background color of the canvas.

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

of course you do. Your compiler will most likely produce errors or warnings if you don't.

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

The code you posted called clock(), not ctime(). Yes, clock() does that, but that's now what you said.

clock() returns clock_t object, which may or may not be double.

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

very limited knowledge of this but this using ctime appears to give a rough time the code took to run.

If you don't know what a function does then you should look it up. ctime() has nothing to do with how long the code has run.

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

Look in the purple ribbon near the top of the screen. Clikc the link CONTROL PANEL

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

use a debugger and you should be able to step into the interrupt function. I don't know what code it executes but at some point it will have to access the keyboard device driver. You can install your own int16h interrupt handler but that is not advisable.

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

never heard of that header file. What is it supposed to do?

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

You need another loop. Are the student loads separated by + symbol as shown?

Delete line 53 -- do NOT close the file here.

ifstream& getload(ifstream& File)
{
   // read one student load
   return File;
}

int main()
{
   ifstream File("filename.txt");
   while( getload(File) )
   {
      char x[3]; // read the line with the + symbol
      File.getline(x,sizeof(x));
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

int 16h is keyboard interface. Put the desired function in ah and issue int 16h interrupt. See this link for one of many links that describe the services. When ah is 0 (as in xor ax,ax) then int16h will wait for keystroke.

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

time() returns the current system date/time in seconds since about 1 Jan 1970 (epoch time)

localtime() will return a tm structure based on the time_t value that was returned by time() or other similar function.

ctime() returns a character array based on the contents of struct tm that is passed to ctime()

Briefly

time_t now = time(0);
struct tm* tm = localtime(&now);
char* s = ctime(tm);
Nick Evan commented: Short & sweet +16
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Oh now I see -- I had never used that link, didn't realize that date was clickable :$

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

1.5 is a double, 1.5F is a float

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

Huh??? If you are talking about that purple circle that looks like a dart board, I was always able to do that

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

Simple -- just click on the desktop icon then run your compiler and/or program from within the dos box that it creates.

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

I'm not surprised. Install the DOSBox emulator.

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

Its compiler dependent -- compilers are free to use any extension they please. Microsoft uses *.cpp, while g++ and MinGW use *.cc, although both compilers can be set up to recognize other extensions.

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

>>I haven't seen NULL defined as (char*)0

Most MS-DOS compilers defined it that way before c++ and void keyword were invented. But of course you are correct that void* is now used instead of char*.

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

Code::Blocks and Fedora are two completely different things -- Code::Blocks is an IDE that runs with Fedora. You can't use Code::Blocks without an operating system, whether its Fedora or some other *nix distribution. You can not compile programs with Fedora because Fedora is not a compiler.

Maybe you want to ask about the difference between g++, which is the default compiler for *nix, and Code::Blocks. There again, Code::Blocks is just an IDE, not a compiler, while g++ is a compiler and not an IDE. Code::Blocks calls g++ to compile the programs.

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

Of course there are other files/folders. The os contains thousands of them.

I suspect you have a failure to communicate correctly. Is English not your first language?

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

When you start the program it sets the current working dirfectory to the folder which clontains the source files. So if you put that file in the debug folder then you copied it to the wrong folder. Put the file in the same folder as the *.c and *.cpp files.

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

Since a shell is a user-interface to the os I suppose there may be versions of *nix which run without a shell and without human interface. I think those would be pretty rare cases.

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

Not that I am aware of. If you want to add it as a parameter to a function then just do it yourself, such as foo("MyFunction");

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

All the functions found in string.h expect character arrays to be terminated with a '\0' character. For example char Hello[] = {'H','E','L','L','O','\0'} An easier way to code the same is char Hello[] = "Hello"; In that case the compiler will add the '\0' character to the end of the string for you.


NULL is a macro which is normally used with pointers, such as char* Hello = NULL; The exact definition of NULL is compiler dependent, but normally defined as either (char *)0 or just 0.

BTW there is no difference between '\0' and 0, they are interchangable.

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

Some compiler IDEs such as Microsoft can provide that information, but C and C++ lcnaugages know nothing about function names -- only addresses.

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

Code::Blocks is an IDE that can be used on both MS-Windows and *nix, while Fedora is an operating system.

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

>>When is not going to be available a shell?
Some embedded systems don't have a shell. I have not used all operatin gsystems so I suppose there could be a few others out there too that don't have shells. MS-Windows and *nix will always have one available.

Instead of testing system(NULL) why not simply test system(myprog)? Why bother calling system() twice when once will do.

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

You can not use / characters in file name. The best format is YYYYMMDD (Year Month Day)format because such file names can be easily sorted sorrecty.

To get the system time use the localtime() function found in time.h. That will return a structure that you can use either sprintf() or strftime() to format the time into a character array.

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

Whether to use internal or external hard drive will depend on how much disk space all those games will consume. Since you have such a huge internal hard drive I would put them there if they take less than a couple hundred gb.