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

I cannot get things to work on my Windows 7 PC.

What kinds of problems are you having? As I recll from 25 years ago dBase ran under MS-DOS version 6.X and earlier. Under Windows 7 you may have to install DOSBox and run it in that environment.Click Here

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

VS has never recognized anything other than .h extension by default, so I doubt that is the problem. Most likely the .h file was added to the project as a compileable file just like the .cpp files. If that is the case then just simply remove the file from solution. Don't delete it from the file system or project folder, just from VS Solution Explorer window.

rubberman commented: Thanks AD - I haven't used VS for a LONG time. I'd rather get a good whack upside the head instead! :-) +12
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

header files are not to be compiled, they are just included in other *.c and *.cpp files.

// some \*.cpp file
#include <iostream>
#include "SalesP.h"

// rest of cpp code goes here
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

As I recall it was a Unix computer that beat the world chess champion about 10-15 years ago. Pretty impressive feat, I doubt MS-Windows could have done that.

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

Not that I know of. I don't know very much about java. But you might be able to use the same IDE, such as NetBeans (don't know about it either).

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

There's generally two layers of software -- os kernel which has direct access to all hardware, and application programs which are protected from direct hardware access. What you are asking is how to write os device drivers, which run at the kernel level. For MS-Windows you will need these tools. Here are some other links and tutorials to get you started.

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

You never answered the last question, the problem states it's supposed to be in java.

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

Do you mean this one?

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

I already told you what's wrong with it, reread my previous post, second paragraph. You have the && and || operators mixed up. Sometimes even more experienced programmers have that problem.

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

line 10 is still wrong -- you failed to make the correction I pointed out. The pogram isn't going to work unless you increase the size of those two variables.

line 23: use && instead of ||. Let's say you enter "mm". Line 23 is going to fail because it's not "nm", so you need the && operator to say if it's not any of those strings.

line 41: Think about what the && operator does, according to line 41 you expect init_unit to be both "mm" and "cm" at the same time. Not possible. You need the || operator instead of && operator.

All the other lines foollowing line 41 are using the wrong && operator for the same reason as I mentioned above.

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

class of girls with their ages and phone numbers (a little black book).

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

That means I have to declare as char init_unit[2] and sec_unit[2].

No, declare as char init_unit[3], sec_unit[3];

How do I take care of the parts where I have else if from line 58 downwards

By calling stramp() similar to how I showed you in my last post.

That would all be simpler if you used std::string instead of char arrays.

std::string init_unit, sec_unit;

Then you can use the == operator like you did, but still have to put the two characters in double quotes, such as "mm" istead of 'mm'

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

You need to fix all the compiler errors before you attempt to run the program.

the two variables declared on line 9 are too small if you expect to enter two characters on line 21. cin will add a string null terminating character, so increase the size of the two variables by 1 byte each.

if (init_unit != 'mm' || init_unit != 'cm' || init_unit != 'm' || init_unit != 'km')

Two characters must be enclosed in double quotes, such as "mm". and since init_unit is a character array you can't use == operator to compare it with another character array

 if ( strcmp(init_unit,"mm") != 0 ||  strcmp(init_unit,"cm") != 0 ||  strcmp(init_unit,"m") != 0 ||  strcmp(init_unit,"km") != 0)

You have the same problem in many other lines in that program.

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

This one shows the mouse over the variable, and I tried to click on it, to make it expand,

It won't expand if the variable is just a pointer because the debugger has no idea how many elements are in the array, or even if it is an array at all.

But if it's an array and not a pointer than click the + that's in the box just before the variable name.

AD: Do you mean in the Watch Window?

No.

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

The only way I know to do that is to move the cursor on the array name then an + will appear, select the + and it will show all array elements. You can even do that for linked lists, but only one node at a time. It doesn't work like that for pointers to arrays.

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

Lines 23 and 43 write text files, not binary files. If you want binary file then. You can't write binary then expect to read it as text, or vice versa.

os.write((void*)&os, sizeof(os));

and

os.read((void*)&os, sizeof(os));

On MS_Windows it's dangerous to attempt to write both text and binary into the same file because of the way '\n' is physically written to the hard drive -- it's actually written as two bytes, not one. *nix doesn't have that problem.

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

How do I go about doing that?

Easy -- whenever a swap is needed swap the data that's within the two nodes instead of the pointers. If there are several data items in the nodes then I'd put the data in a structure and the structure object with the node. That will make swaping much easier.

struct data
{
   int x,y,z;
   char stuff[80];
};

struct node
{
   struct node* next;
   struct node* prev;
   struct data dat;
}

void swap(struct node* n1, struct node* n2)
{
   struct data temp;
   temp = n1->dat;
   n1->dat = n2->dat;
   n2->dat = temp;

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

Rather than attempting to swap link pointers it is a lot easier to swap the data and leave all the pointers alone.

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

I had a similar problem with a laptop, no screen or wifi driver.

FreeDOS is too heavy

How big a hard drive is in that computer? old DOS and FreeDOS don't dupport anything larger than about 2 TB (according to this link)

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

While it is lagging I pinged Daniweb.com in a command prompt and got pretty quick responses.

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

I think it may be because there's a pointer inthe struct declaration,

Nope, it has nothing to do with that pointer, unless there is no memory allocated to the pointer.

The problem looks like Teams is not an array but a single instance of the structure. If you want Teams to be an array then

void searchAndTally(NBA_Team teams[], char team[], bool WL)

or

void searchAndTally(NBA_Team* teams, char team[], bool WL)

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

Yes, you can write your own, but since you mentioned xmove.exe I assumed you wanted MS-DOS. Be prepared to write assembly language.

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

If you are talking about MS-DOS 6.X and earlier, you don't "creat it". You get it from Microoft, assuming they still have it. There's also Dr DOS, which is MS-DOS like. But neither are supported any more because they're too old and nobody uses them. Here is a link that tells about the various versions and who write them.

You can still buy MS-DOS 6 from amazon.com for $70.00 USD

I prefer xmove in place of Cut & Paste

Windows File Explorer can do something like xmove.

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

It happened again to me just now.

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

Sometimes I click a menu and nothing happens for a long time. Other times I double post because I didn't think anything happened when I clicked the Submit button.

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

You need to pass Number to assign() by reference, not by value so that assign() can change the structure that is declared in main().

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

Some compilers let you select the padding size, or no padding at all regardless of what the members of the structure consist of. If I'm writing a program to transfer structures to another system then I use no padding. The problem with that is accessing members may be a little slower.

#pragma pack(0) // no padding
struct foo
{
   char name[20];
   int x;
   int y;
}
#pragma pack() // return to default
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The program is doing integer division which means no fractions because number1 and number2 are both integers. You can correct the problem by typcasting either the numerator or demoninator to float

correctanswer = (float)number1 / number2;

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

So why shouldn't I put everything in PCHs?

That is a compiler-generated file, you can't do anything with it except delete it when it's no longer needed.

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

Everything in stdafx.h is included in precompiled headers.

Yes, the linker only links into the executable the functions etc. that are actually referenced in the program or one of the libraries that the program uses. It's just standard, normal linking and is the same with or without precompiled headers.

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

I assume you are using one of the Microsoft c++ compilers. If you want precompiled headers then every *.cpp file in the project must include stdafx.h as the first header file. You can include any others you want after that.

#include "stdafx.h" // precompiled header file goes first
#include "myclass.h" // now all others you want 
#include "anotherclass.h"

Your project will also have stdafx.cpp, which is the first *.cpp file that the comopiler will compile, and the compiler generates the *.pch file at that time. The *.pch file contains all the pre-processed files that are in stdafx.h. This greatly speeds up the compilation of large projects because the compiler doesn't have to read all the includes for every *.cpp file.

Precompiled headers do not work the C programs, it's C++ only. If your project is a mixture of both c++ and C files then you will have to manually turn off precompiled header options for all the C files.

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

It worked for me

Enter size of array:
5
Enter elements: 1 2 3 4 5
The elements after shifting the array:
0
1
2
3
4
5
Press any key to continue . . .

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

pritaeas just deleted a duplicate post of mine and now the post reply count is 0 even though there is still 1 reply. I recall someone else reported the same issue a few days ago.

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

In the loop on lines 4-8, where is buffer incremented? line 4 always looks at the same character, which is why it's an infinite loop, unless buffer[0] == '\0'

Try this loop

while(buffer[a] != '\0')
    {
        cout << buffer[a];
        a++ ;
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your program looks correct -- what are you confused about?

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

Just call getline() which will do all that for you.

ifstream in("filename.txt");
char buf[80];
while( in.getline(buf,sizeof(buf)) )
{
   // do something
   cout << buf << '\n';
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

At one time there was a link at the bottom of the page to all the archived newsletters. I haven't seen it for a long time now. Too bad.

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

When p is an integer pointer then p++ incrments by sizeof(int), not by sizeof(int *), and the code he posted proves it. Had p been a pointer to an array of char, then p++ would have incremented by sizeof(char), or 1.

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

Although what you said is correct, the question was why did the pointer increment by 2 instead of 4, which is not the same as the answer you provided. I think you misunderstood the question. In the question, the number of bytes by which the pointer is incremented is the sizeof one element of the array.

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

you can easily find out the size of an int by printing sizeof(int) -- but to answer your question, on most 32-bit compilers sizeof(int) == 4. If you are accustomed to using Turbo C, that is a 16-bit compiler and sizeof(int) == sizeof(short) == 2. But on most modern compilers sizeof(int) is not the same as sizeof(short). It's never a good idea to outguess the size of integers becaue it can vary from one compiler to another, and the C standards make no such assumption.

printf("sizeof(short) = %d\n", sizeof(short));
printf("sizeof(int) = %d\n", sizeof(int));
printf("sizeof(long) = %d\n", sizeof(long));
printf("sizeof(long long) = %d\n", sizeof(long long));
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Banfa -- gives very good explanations

http://www.daniweb.com/members/724268/Banfa

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

You have break statements in the wrong place.

Move the break statement on line 42 down to line 71.

Move the break statement on line 78 down to just below line 98.

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

Almost all games and other major programs consists of many many files. What you learn in school only scratches the surface of what occurs in real life programs. Example: Notepad.exe probably consists of at least 50 *.c and *.h files. Every program you use in MS-Windows and *nix consist of a lot of files. Some programs consist of over a million lines of code -- can you imagine all that in a sincle file??

you will eventually write programs that consist of multiple files. That is done to keep things simple and organized into logical units.

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

Lets say you have two files A.cpp and B.cpp, each of them use the functions that are in functions.h. If you put the code directly in fuctions.h the linker will spit out duplicate function error messages for all the functions in functions.h. That's the main reason to put the functions in functions.cpp and the prototypes in functions.h. Can you immage the errors the compiler will spit out if you have 100 *.cpp files in the same program and each of them include functions.h???

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

maybe something like this:

void mystrcat(char* dest, const char* source)
{
   while(*dest)
      dest++;
   while(*source)
      *dest++ = source++;
   *dest = 0;
 }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

functions.lib

Don't do that! name it functions.c or functions.cpp. functions.lib should be the name of the library, not the name of the source file.

In Code::Blocks start a new library project and put all the functions you want in it. When CB compiles it CB will generate the functions.lib file for you.

To add your library to a project, go to menu Settings --> Compiler, then click the Linker Settings tab.

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

I like Visual Studio 2014, but it has a rather long and sometimes difficult learning curve. IMO the next best thing is Code::Blocks with MinGW compiler -- it's portable between *nix and MS-Windows where VS isn't.

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

What verson of Borland compiler are you using? Many of the old 16-bit Borland compilers were created before the c++ standards and require *.h file extension

// cin with strings
#include <iostream.h>
#include <string.h>
#include <conio.h>
//using namespace std;
int main ()
{
string mystr;
cout << "What's your name? ";
getline (cin, mystr);
cout << "Hello " << mystr << ".\n";
cout << "What is your favorite team? ";
getline (cin, mystr);
cout << "I like " << mystr << " too!\n";
getch();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Header files only contain function prototypes, not the functions themselves. You need to put the functions in a library. To use them just link the program with the library (*.a, *.so or *.lib) just as you would with all other standard compiler libraries.

how to create a library depends on the compiler you are using, there is no standard way to do it. Generally, put the functions in one or more *.c or *.cpp files, compile them (but do not link) to object module (either *.o or *.obj) then have your compiler add them to the library. If you are working with *nix, it has an ar pogram that can put the object modules into a library.

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

If I remove the myTicketFineCalculator then I get an error that getFine() isn't declared.

I didn't ask you to remove myTicketFineCalulator from that line. Just change the number of parameters.

totalFine = myTicketFineCalculator.getFine(totalFine); //This is where i am having issues calling the function

That is from your original post -- have you changed it? Maybe you should repost the code snippet that you originally posted so we can see what changes you made.