Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Tall order, but I'd be the last person to tell you it can't be done, so go for it!

like Java for operating systems that have Java but I have no access to)

This sentence confused me a bit. Are you saying you don't have Java on your system, or did you mean you don't have access to the other operating systems? It isn't very clear.

As for not using system calls, I assume you mean that it can't call the system directly; you most certainly do use system calls for the standard iostream operations, they're just hidden behind an abstraction layer.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Not necessarily, I hope. If you look at the Google book I'd linked earlier, you'll see that there was also a chdir() (change directory) function, which should let you use directories other than the one you started in. You'd still be limited to the DOS environment, but you could at least move around among the directories. Keep in mind also that directories with long names can still be referenced by shorter, mangled names, for example, "C:\Documents and Settings\" becomes "C:\DOCUME~1\" for DOS programs. If all else fails, you can put the Reports directory in the root directory, as "C:\Reports". At least I am hoping that should work.

Don't forget to check if the directory exists (using searchpath() , I think); if it doesn't, use mkdir() to create it before you use it.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

i want to create an array of objects to reference then loop through searching the objects, but in the main function it says I cant create an array of my objects any ideas how I can overcome this

Odd, it certainly should allow you to create such an array. Could you post the code you had tried to use, and the exact error messages you were getting?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

do you mean just do it all in a main function

No; quite the opposite, in fact. What v3ga was talking about was the getBall[i]x[/i]() functions, versus the single getBall() function I proposed. What he meant was that having six separate functions which do more or less the same operation is a bad design approach; it is better to have a single function that takes a parameter to decide which of the six you should be operating on.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

While I have never seen a virtual machine which interpreted the assembly code directly, I'm sure it would work and I expect it has been done before. A bytecode would be much easier to interpret, but would require some sort of additional software - an assembler or a compiler for a higher-level language - to make programming it practical. Conversely, you wouldn't need a separate translator with the assembly approach, but it would take more work to interpret - you would, in effect, be combining the assembler with the interpreter.

By the way, I don't see any code for handling labels, traditionally the most important - or at least trickiest - part of assembling, such that the vast majority of assemblers have a separate pass just to collect the relative locations of the labels. What did you mean to do about backwards references? Or did you intend to handle all the jump calculations manually?

I would definitely say that a switch() is going to be easier for a lot of the code, at least with regards to the opcodes themselves.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Before we proceed, could you also tell us the assembly program you are using (e.g., MASM, GAS, NASM, FASM, etc.)? Each assembler uses a different variation on the assembly language syntax, and some of them are quite different from the others.

For that matter, while some of the mnemonics you mention look like the GAS versions, but others don't seem familiar at all, which makes me wonder what the CPU you are targeting is.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Cross-posting is generally frowned upon, as it causes a duplication of effort on the parts of the two groups.

zeroliken commented: and there's the proof +5
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

On a conceptual level, I would recommend looking into the Flyweight pattern. The basic principle is to have a class which represents the common aspects of the objects (e.g., sprite sheets) as class members, then have the Flyweight objects instantiate just the details which the specific object needs (e.g., position, color map). The Wikipedia page has a decent example of how to write a Flyweight class and Flyweight Factory (which also allows you to avoid repeated memory allocations by having a pre-existing pool of Flyweight objects to draw from).

On a practical level, you would probably have some abstract parent class for all of the objects you are using (the Flyweight class), and a Factory class which would be used to produce (or retrieve) objects of the appropriate sub-class. The Flyweight class would provide an interface for the shared behaviors, as well as holding any properties shared by all members as class ( static ) variables. The Flyweight Factory class would have a method that takes some sort of marker that indicates which subclass of the Flyweight class to use, as well as any properties specific to the Flyweight object; it would check to see if any objects of that sub-class already exist, and if so, returns one of them, otherwise, it would create a new object of the desired sub-class and return that. The parent Flyweight class (and it's sub-classes) would hold the shared information as static class variables; only the specifics of the …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

No, there isn't any form of numeric literals for binary numbers in C++. Using the bitwise operators as you've shown is probably your best bet, though using hex would probably make more sense than decimal.

if((0xb9 & 0x95) == 0x91){
        //Do code "0x91"
}

The reason why hex makes sense for this is because 16 is an even power of 2, hence the digit places 'line up' evenly with the bits. For example, 10 hex is equal to 00010000 binary. Decimal values do not 'line up' with binary values in this manner, making it harder to see the patterns in the bit values.

If it helps, you might want to take a look at some existing virtual machines, such as the classic P-code Machine, which is remarkably simple (though written in Pascal, which may be unfamiliar to you). My own Pmac virtual machine might also prove helpful.

Why 640K memory, BTW? How are you handling the addressing fields?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

If you go back to your original design,

#include <iostream> 
#include<cmath>
using namespace std;
int main()
{   
    int n=4;
    for ( int i=n;i>0;i--)
    {
        for (int space=i; space <n; space++)
        {
            cout<<" ";
            for (int j=1;j<=(2*i-1); j++)
                cout<<"*";
        }
        cout<<endl;
    }
    return 0;
}

and modify it, it is a viable approach (sort of). First off, you want to move the for() loop that writes the asterisks out of the spacing loop. Second, try making i = 8 to start, and instead of decrementing by one, decrement by 2.

for (int i = 2 * n; i > 0; i -= 2)

You'll need to adjust the spacing loop accordingly.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

OK, then. For the student structure, add this to the student structure:

void write(std::ostream& outfile);

Then the implementation would go something like:

void student::write(std::ostream& outfile)
{
    outfile << admno << ',';
    outfile << name  << ','; 

    for (int i = 0; i < 5; i++)
    {
        outfile << marks[i] << ',';
    }

    outfile << perc << std::endl;
}

This is just an example of one way to do it, but it is probably the most straightforward, and has the advantage that the resulting file can be read in a standard text editor.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

In this case, it is simply a matter of writing out the individual elements of the structure in some appropriate order. It doesn't have to be anything fancy; a comma-separated values (CSV) file will do the trick, I would expect. Can you post the structure in question?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

You may find my Passim assembler useful as a guide for tokenizing and symbol table manipulation. While it is in C rather than C++, it should be familiar enough to make sense out of.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Did you create your project as a CLR project? System::Convert is part of the .Net framework, and only .Net programs (which in C++ means Common Language Runtime programs) can use those classes.

Also, did you make sure to include the necessary headers?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Colors are usually represented by three color gradients (either Red-Green-Blue for 'additive color' or Cyan-Yellow-Magenta for 'subtractive color'). This is because the human eye can differentiate three different clusters of wavelengths, with some overlap, so colors 'between' the main detected colors, such as orange, are actually detected by the green and red receptors, and so appear as a combination of the two.

Why am I mentioning all of this? Because you are using four sets of colors to represent the spectrum, which is unusual. What does the fourth number represent: 'pure' black (as with the 'Key' of the CMYK model? Pure white? Grayscale or 'tone'? An Alpha channel (transparency)? Or do you know at all? All this may be relevant to how you store the numbers, as is Moschops question about the range of the values (because that will tell you how many bits you'll need to represent each color).

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I would attend to the 'walking through walls' issue first, as the solution to the gravity issue will depend on being able to detect the floor. How are you doing collision detection in general? You might want to go over a few tutorials on the subject such as this one and this one, if you haven't already. It isn't a minor topic - entire books have been written on the subject - but for most purposes, BSP trees are still probably the easiest efficient solution; the chapter on it in Michael Abrash's Graphics Programming Black Book remains an excellent primer on it even after fiteen years.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

What it is complaining about is the fact that you have the prototypes for the functions, but the functions themselves aren't implemented anywhere. In other words, the functions are declared, but not defined. You need to have the actual implementation somewhere, either in this file or in another one which is linked with it at compile time.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

What you are looking to do is what is called tokenization, the process of breaking an input stream into tokens. Given the type of data you're working with, it shouldn't be very difficult. The usual solution is to go through the input character by character to find where the current token ends:

char* getToken(char* src, char* dest)
{
    while (!isspace(*src))
    {
        dest++ = src++;  
    }
    
    return src;   // return a pointer to the current position in the source string
}

This is a pretty generic approach to tokenizing; it isn't that different from what the standard function strtok() does, in fact, though with strtok() you can set different types of delimiters.

The tricky part comes when you go to interpret the meaning of the tokens. Since you need to be able to tell when something is a label, versus an mnemonic, versus an argument, you will want to have a first pass that does nothing but collect the labels (and their positions, which is the real main purpose of the first pass anyway) and put them in a table. You need to read in the first token of a line, and if it isn't an mnemonic, put it into the label table. If it is an mnemonic, you need to advance the position in the output file by one; you also need to check whether that mnemonic takes an argument or not, and if it does, check that there is another token on the line (the argument) - …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

OK, when you open the file, you should check that the file is actually opened. The specific error code may give you some insight as to why it is failing.

report.open(fname, ios::out);
    if (!report.is_open())
    {
        cerr << "File " << fname << " could not be opened.";
    }

Similarly, test after read write out to the file, to see if the write was successful.

report << s.admno;
    if (report.fail())
    {
        cerr << "Unable to write the admission number to file " << fname;
        report.clear();
    }

I realize that this is tedious, but it is the best way to ensure that the file is written correctly.

On a possibly related note, I see that you are trying to write out the variable s directly to the file. You cannot effectively do this with a structure, however; all you'll get it the pointer to the structure, not the values inside of it. Even if it were to write the structure, the data would be useless, as any pointers or offsets would be invalid when you try to read it back. You need to write out the individual elements of the structure (a process called serialization) in order to get a useful value written to the file.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Assuming you are using an ifstream to read the file, then function you want is seekg() , which allows you to set the 'get pointer' in a file stream (the point at which the next read will begin). If you follow that link, it has an example of how it is used.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

OK, and do either of these appear in VariableSetup.cpp ?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

This looks to have something to do with the Battlefront.h and Battlefront.cpp files, rather than with the code shown here. Specifically, it has to do with two variables (or possibly functions) named MainWindow and Mode . Could you show where these are declared?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I could, but WaltP would jump all over me for it :P

Seriously, yes, but you have to keep in mind that this is only an example; it doesn't really do much other than repeat back the words. I used your existing code as a framework for the example.

#include <iostream>
#include <cstring>

using namespace std;

int const BUFSIZE = 256;     // use an arbitrarily large buffer that is unlikely to get overrun

int main ()
{
    char buffer[BUFSIZE];
    char **a;
    int N;
    cout<<"Enter the number of words = ";
    cin>>N;
    cin.ignore();    // clear out the excess characters from the buffer
    a = new char*[N]; // allocate the array of strings

    for(int i=0; i<N; i++)
    {
        cout<<"Enter word number "<<i<<" : ";
        cin.get(buffer, BUFSIZE);
        
        int size = strlen(buffer);  // get the size of the string 
        a[i] = new char[size + 1];  // allocate enough space for the string and it's delimiter
        strcpy(a[i], buffer);       // copy the string from the buffer to the new char array
        cin.ignore();
    }

    for(int i=0; i<N; i++)
    {
        cout << a[i] << endl;       // print out the word
        delete[] a[i];
    }

    delete[] a;
    return 0;

}
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Za? That's... bizarre. I'll have to see what I can find about that file.

In the meanwhile, can you post the whole, exact error message that you're getting, as well as the current version of the PlayerClass header?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Fair enough.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

And not a memory hog.

Seriously? True, the iterative version of factorial is O(1) in memory, whereas recursive factorial is O(n) in memory. Assuming that a stack frame is, 32 bytes (assuming a 64-bit unsigned long , 64-bit memory addressing, and no register painting) that would amount to 8KiB for 256! (even if you could, with a 64 bit value). How often do you really compute 256! ? Even on an embedded system, that is hardly a memory hog.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

No, this won't work, you are correct. What you'll need to do is have a large buffer to read the C-string into, then get the size of the string using strlen() , and only then should you allocate the memory to hold the word. Alternately, you can use the string class and avoid the issue entirely.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

The problem is occurring because you are using the initialization syntax for what is in fact not initialization. When you are setting the value of a variable that is declared elsewhere, you cannot use the initialization syntax for an assignment, even if you had not yet set the variable. You need to set each member of the array separately.

khanthegamer commented: the dude knows what he's talkin about +0
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

While it isn't necessarily how I would do it, it does seem to be a valid approach to the problem. The only thing I see wrong with it is that you need to add the header for <iostream> , and a using namespace std; directive.

#include <iostream>

using namespace std;

If you add these at the beginning of the program, it should compile correctly and run.

Have you tried running it yet? Which compiler are you using, and do you need any help with using it correctly?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Given the number of balls in play, it may be better to have a generalized get_Ball() function which take an index argument:

int get_Ball(int ball_no)
    {
        return balls[ball_no - 1]; 
    }

You could even write it as an operator[] function which would allow you to treat it similarly to an array.

OTOH, I'm not sure you want a set_Ball() function at all. The entire point of this is to generate the balls randomly, correct? If so, that should be a (private) operation of the Lottery machine object - setting or changing the values from outside of the lottery machine ought to be prevented. Similarly, the c'tor shouldn't have to take the generated values in at the start, because the purpose of the Lottery object is to do the generating for you.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Have you tried searching for the file elsewhere on the drive, and did it show up anywhere?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Now, now, there's no need to shout.

I gather that the manipulator I'd recommended earlier didn't work? Or is this a further question about how to get the appropriate field spacing? Ordinarily, I'd say use

cout << setw(4)  << setfill('0') << hex << temp.lc
     << setw(4)  << setfill(' ') << " "
     << setw(16) << temp.label
     << setw(8)  << temp.opcode
     << setw(8)  << temp.operand 
     << endl;

... but I'm not certain if it would work under such an old compiler. Also, it is not exactly the same as your original statement (it uses field widths instead of tabs), but it should work out to the same output in almost all cases.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Dakot: while I would agree in general that using the standard sorting function is the best solution for most cases, in this instance this is clearly a homework problem, and writing the sorting function is the main objective. Also, the OP seems to be using an older compiler (probably Turbo C++ 3.0), which almost certainly does not include the <algorithm> header and library.

As for the OP's problem, I would check out the description of bubble sort on Wikipedia, as it has a nice animation showing how the sorting takes place. That may help you visualize the solution better. Alternatively, you could try using Gnome Sort, which is a bit simpler but not so obvious as bubble sort (which is traditionally seen as a 'naive' algorithm, that is to say, it is one most people would stumble upon if asked to make up a way to sort things without help).

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

What is the specific error that is occurring? Is it failing to compile, and if so, what does the error message say?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Could you post the exact error message you are getting, please?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

In the future, please put all code samples inside of code-tags. The forum software does not retain indentation by default, so without the code tags the formatting is lost, making it hard to read the code.

Here is your code with suitable formatting (courtesy of AStyle):

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

int main()
{
    int a[20];
    int i, p, j, sum, lar,sma, an, lar1, lar2; /*i for the number and p for the association of th number*/

    i=0;
    sum=0;
    lar=0;
    sma=100000;
    do
    {
        printf(" Enter %d:",i);
        scanf("%d",&p);                 /*I use p as my input*/
        a[i] = p;                       /*I use i for my Array*/
        i=i+1;
        if(p>lar)
            lar=p;
        if(p<lar && !=lar)
            lar1=p;
        if (p<lar1 && !=lar1)
            lar2=p;
    }
    while(i<20);

    j=i;
    i=0;
    do
    {
        printf("a[%d] = %d\n", i, a[i]);
        i=i+1;
    }
    while(i<j);                              /*I use J as my bonus*/
    printf("\n\nThe sum of all this arrays is %d",sum);
    printf("\nThe largest number is %d",lar);
    printf("\nThe smalest number is %d",sma);
    getch();
}

Now that we can read the code, can you tell us what problems you are having with it? While I can see that it does not sort the values (I would recommend reading up on Sorting Algorithms), it would help if you could tell us in your own words what the problem is.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

If you #include the header, but not the implementation file, then the other files should recognize the class, without the multiple definition problem. See here for more details.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

so my switch statement with

char letter;

wouldn't work?

Not the way you have it, no, but not because it is a char .

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Letter is a char variable. Instead of holding a letter of the alphabet that the user entered in, it now holds a single digit integer (which, I believe, a char CAN do).

Yes, after a fashion, it can. However, it is in the form of a binary number, rather than a character representing the specific digit. As I said in my last post, these are not the same thing. Also, printing such a single-byte number is likely to present a problem, as the standard printing functions assume that the character is encoded in ASCII or something similar.

So, perhaps I could send my variable "letter" into the necessary functions to make my program work properly. Is this a viable method?

Not if they are expecting a character value, no.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

No, because the line indicates a fundamental misunderstanding of how variables, characters and integers are (un-)related. If you look at the ASCII Table, you will see that the characters which represent the digits are not the same as the integers themselves.

What may not seem as clear is that a variable with an identifier that is a given letter does not have anything to do with the character as a value. If you have a variable A, the variable does not necessarily hold the value 'A', and it cannot be matched to 'A' unless you actually assign that value to it.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Try changing the sprintf() like this:

sprintf(fname, "%s\\Reports\\%d.txt", directory, s.admno);

The '%s' is used to interpolate strings, while '%d' is used to interpolate decimal integers. When you use '%d' on a C-string - which is, after all, just a pointer - you get the address of the string in question.

You also need to use double backslashes ('\\') for the path, as single backslashes are treated as escape markers. To show the backslash itself, you need to escape the escape character, as it were.

GeekZu commented: Thanks +1
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Are you using C-strings or the string class? For the latter, you can just use string concatenation:

string filename = "admission-" + admitNumber + "_" + name + ".txt";

The string concatenation operator should automagically convert the integer values to a string, so long as there is a string value in the left-hand operand.

For C-strings, you can use sprintf() :

char filename[FILENAME_SIZE];

sprintf(filename, "admission-%d_%s.txt", admitNumber, name);

There's still one problem you may have to deal with: Turbo C++ is a DOS program, and MS-DOS only supported 8.3 filenames (that is, eight characters plus a three character extension). You may run into problems with the size of length of the filename you intend to use.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

According to this textbook, there is a version of <iomanip.h> in Turbo C++ 3.0. Whether it has all of the manipulators you need is another question (those pages aren't part of the freely available sample), but it should at least have a version of the hex manipulator.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I've done some checking, and apparently Turbo C++ did have a version of the header <dir.h> , which may include a getcwd() which you can use. At least, I think that's what this thread implies (look down to the OP's reply to the first answer for the relevant comment).

EDIT: Further checking turns up a Google book copy of Programming in C++ by D. Ravichandran. According to this book, Turbo C++ 3.0 did have a getcwd() function, as well as another named getcurdir() . These should do what you need.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

What you need to remember is that both decimal and hexadecimal are only representations of the integer value, which is actually a binary value. Thus, it is only when you go to display the value that it becomes either decimal or hexadecimal, and the same value can be displayed either way.

To write a hex value an output stream, you will want to use the hex manipulator, which sets the output format for the following numeric fields. For example:

cout << hex << myInteger;
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

What you want to do is have only the class definition in the header, and put the function implementations in yet another file (say, PlayerClass.cpp or something similar). You will need to put the file into your project or Makefile to ensure that it is linked into the executable.
Player.h

#ifndef PLAYER_H
#define PLAYER_H

#include "main.h"

class PlayerClass
{
public:
    PlayerClass(Nationality);   // Constructor
    ~PlayerClass();             // Destructor
    sf::Sprite PlayerFeet;
    sf::Sprite Arms;
    sf::Sprite Body;
    sf::Sprite Head;
    int HitPoints;
    GameClass CurrentClass;
};

#endif

Player.cpp

#include "main.h"
#include "Player.h"

PlayerClass::PlayerClass(Nationality natl)
{
    PlayerFeet.SetImage(iFeet);
    HitPoints = 100;
    CurrentClass = SCOUT_SNIPER;
    if(natl == UK)
    {
        Arms.SetImage(iUK_Arms);
        Body.SetImage(iUK_Body);
        Head.SetImage(iUK_Head);
    }
    else
    {
        Arms.SetImage(iNZ_Arms);
        Body.SetImage(iNZ_Body);
        Head.SetImage(iNZ_Head);
    }
}
PlayerClass::~PlayerClass()
{
}
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Cant use std::strings .The code should be compatible with turbo C++ v3 .

Yes, but you are already using <iostream> (without the '.h' extension) and using namespace std; , neither of which would work with TC++. Or are you developing with a different compiler first and back-porting it to Turbo C++?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I think I've tracked down another issue to fix. In the display_list() function, you have a clause

if(current_ptr == NULL)
	{
		cout<<"\n\t\t\tNO RECORDS TO BE DISPLAY \n"<<endl;
	}
	
	else(current_ptr != NULL);
	{
                // and so forth...

The (current_ptr != NULL); part is redundant; you've already tested for the null pointer. worse, because it ends in a semi-colon, it causes that conditional statement to be treated as if it were the only thing guarded by the else statement. if you remove the (current_ptr != NULL); entirely, then it will prevent some of the segfaults you are experiencing.

I also suspect that the line

while (current_ptr->next != NULL); //loop until the end of list

should actually be

while (current_ptr != NULL); //loop until the end of list

... as you've already advanced the pointer at that stage.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I could be wrong, but I think the problem is in the insert_node() function, specifically this clause

else
			{
				before_ptr->next = new_rec_ptr;
				new_rec_ptr = after_ptr;
			}

I'm pretty sure you meant for this to be

else
			{
				before_ptr->next = new_rec_ptr;
				new_rec_ptr->next = after_ptr;
			}

I've also noted a problem in the display_list() function, with this clause:

head_ptr = head_ptr->next; //set current ptr to next node
        	}
				while (head_ptr->next != NULL); //loop until the end of list

It presumably should have been:

current_ptr = current_ptr->next; //set current ptr to next node
        }
        while (current_ptr->next != NULL); //loop until the end of list

However, I'm still getting the problem you describe, so these are not the cause of it. I'll keep looking into this for you.

Oh, and I noticed that you repeat the same display operations for the shoe records in several places, so you might want to add a function for it:

void write_record(ostream& output, shoes_node* rec)
{
        output<<"\n\t\t\t SHOES'S ID	: "<<rec->idkasut<<endl;
        output<<"\n\t\t\t SHOES'S BRANDS	: "<<rec->jenama<<endl;
        output<<"\n\t\t\t SHOES'S PRICE	: "<<rec->harga<<endl;
        output<<"\n\t\t\t SHOES'S SIZE	: "<<rec->saiz<<endl;
}
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster
string x;
string temp[1] = {x};
char y = 0;
char key[10] = {y};

string a;
string name[1] = {a};
char b = 0;
char grade[10] = {b};

This code doesn't make much sense. First off, there is no advantage of declaring an array with a size of one; it is in effect a the same as a single variable. Second, you are assigning to this array a string value that isn't initialized, so you are in effect getting garbage for the assigned value. Third, you are then assigning a single value (again, uninitialized) to a 10-element array, which AFAIK shouldn't compile as an initialization at all.

I suspect that the problem is that you are confusing the mathematical concept of equality with the programming concepts of assignment and initialization. THis seems borne out by the code following it:

for( int j = 0; j < 10; ++ j)
    {
      fin >> a;
      fin >> b;
       
      if (grade[0] = key[0] )
          ;
      if (grade[1] = key[1] )
          ;
// ...

Where you similarly confuse assignment ('=') and comparison ('==').

When you assign (or initialize, as you have it here) a variable with the value of another variable, it does not create any continued connection between them; it is not saying 'this value is the same as this one', but rather, 'take this value on the right and put it in the variable on the left'. Changing the variable on the right later has no effect on …