Adak 419 Nearly a Posting Virtuoso

It's not called "Macro Hell" for no reason. ;)

Adak 419 Nearly a Posting Virtuoso

You don't want variables up above main() (Global), generally speaking. They are TROUBLE!

Prototype your functions above main() - YES! Same with structs. That way, any function can easily create a local struct, for temporary work.

Passing your variables to functions, ONLY if they need them, and then pass them the address to those variables you pass, ONLY if they need to alter them, is a great way to encapsulate what is going on, inside each function.

That makes bug killing later on, a LOT easier.

Adak 419 Nearly a Posting Virtuoso

To optimize a program:

1) remember your first priority is always an accurate program. A wrong answer might be infinitely fast, but it's still wrong, and probably useless. Get and keep your program accurate.

2) the largest optimizing you can do, (by far), is with the choice of the algorithm for the program. It's not unusual to get a 2 to 20 x faster run time, simply by using a better algorithm. Choose this with care!

3) run the program, with a profiler, and find the bottlenecks. Concentrate your optimizing work on the code where it's needed most.

4) create a small but relevant test case with typical data. You want a test case that runs for one to two minutes. Include run time from the computer, right into your test case. Now you can easily try different optimiziations, easily, and have real data - not the hand waving or hot air theorizing that we see all too often.

If you post your test case on programming boards, you are very likely to get a large response from the members - because they can d/l it and test it themselves, they get more involved.

Adak 419 Nearly a Posting Virtuoso

Your switch statement only deals with numbers up to nine. As Moschops suggests, you need to deal with each digit of the number.

One easy way to do that, is to change the number, into a string of chars. Then deal with each digit in the array of chars.

Adak 419 Nearly a Posting Virtuoso
Adak 419 Nearly a Posting Virtuoso

Instead of explicitly printing every every * with another line of code, you want to use loops and if statements, etc.

Think more like this, in pseudo code:

get the height and the width of the box, from the user
for each row
   move the cursor along the width of the box
   for each column    
      if the column number is the first, or the last one, 
         print a *

      if the row number is the top or the bottom
         print every column with a *
    next column
    print newline
next row    
Adak 419 Nearly a Posting Virtuoso

Would you post the program? I'd have to see how the program is set up to receive input. Also, I want to be sure you actually wrote the password program. I want to avoid even the appearance of helping someone crack a password.

rubberman commented: This is getting a little to "picky" in my opinion -3
Adak 419 Nearly a Posting Virtuoso

Check Google and YouTube for DS and Algo classes (either past classes or upcoming in the Fall). Uni's in the past with classes include MIT, Harvard, Stanford, etc. In some cases you can actually enroll, but you can also just watch the video.

Many particular DS's and Algo's are shown in Wikipedia with applets showing the progress of the program, in action. Several types of sorting, depth first search, etc.

Adak 419 Nearly a Posting Virtuoso

Using Pelles C, you should use the compiler in the IDE. Whatever options you want, you can change the compiler flags being passed to the compiler, right in "Project" ---> "project options".

That way you don't have to keep keyboarding in a bunch of flag options. I use the default options a lot. Use "enable Microsoft extensions", for any program that uses the "windows.h" include file. You should read up on the Pelles C introduction which is included in the help section. There's a lot of stuff there. ;)

The type of project I use is Win32 console. It supports big integers (up into the billions), with unsigned long long int. I have the x64 version (because the PC has a 64 bit OS with 64 bit hardware, but I just don't need anything more than several billion. (I got used to using a work around for counting up as high as I want, from DOS days).

For help with Pelles C, absolutely the best thing is to register (free), on the Pelles C forum, at:
http://forum.pellesc.de/index.php

They have a "Beginner section", although you aren't limited as to where you want to read or post. LOTS of good stuff on there, and you WILL need it, from time to time, so sign up!

Your compiler errors are a result of an earlier error in your program. Post the code, and remember to use the compile button in the IDE, not the command line.

somjit{} commented: lots of helpful details :) +3
Adak 419 Nearly a Posting Virtuoso

You want the "tightest" code which adds a few variables, and multiplies those values two times?

The assembly code the compiler generates will vary, but the execution time and overall size, will be remarkably similar. There aren't many ways a compiler will take to add or multiply.

If you are concerned about minimizing the run-time of your program, this is not the way to do it. You are adding and multiplying a few variables. What possible optimization do you expect to find or receive?

Your programs first priority is always accuracy. Why? Because if you can settle for a wrong answer, a simpleton program can deliver it instantly, everytime.

First then, get the program accurate in it's results. THEN concentrate on run-time optimizing. There are excellent profiling tools that can show you just where your program is spending the majority of it's time. Find those bottlenecks, and see what can be done with streamlining them.

Adak 419 Nearly a Posting Virtuoso

Showing once again why volunteering a program, without the original poster doing any work whatsoever, is a bad idea.

Whether it's homework, or a problem solving website like SPOJ or Euler Project, having us code up a gratis program for them, is just wrong. They did none of the work.

And can you code that in Lisp, Fortran, ADA, Go, Rust, Scheme, Python, Perl, and Brainfuck, for me?

iamthwee commented: nods +14
Adak 419 Nearly a Posting Virtuoso

Any time you venture out into the "weeds" of undefined behavior, the results can be odd or just what you might expect.

The point is, why bother? It's an unproductive line of inquiry at best - a complete mockery of the standards of the C language, and your ability to see the wisdom of working within those standards, at worst.

Adak 419 Nearly a Posting Virtuoso

Your printf() line of code is a great example of programmers being oh-so clever, while ignoring the virtue of clarity in their code.

If you had written that line of code for me, as your employer, I would give you one warning - and on the next occassion, FIRE YOU, immediately.

Programs are not gilded showcases for your mental gymnastics of code. When a program needs to be modified, de-bugged, or worked on by someone else, the value of being clear, rather than unnecessarily complex, will immediately become apparent.

Adak 419 Nearly a Posting Virtuoso

By "only a single row of text", I mean that conceptually, even a multi-line replacement, is handled just one line at a time.

Every system has a sweet spot for the number of rows to hold in the 2D char array, for fastest edits.

Adak 419 Nearly a Posting Virtuoso

I strongly recommend you switch to the Pelles C IDE & compiler. It's based on the llc compiler, iirc.

I use it for all Windows based C programming, and couldn't be happier. Any questions I have about it, get answered here:

http://forum.pellesc.de/index.php

quickly and authoritatively. :)

Adak 419 Nearly a Posting Virtuoso

Try Super sed. (for Windows command line, I believe).
http://sed.sourceforge.net/grabbag/ssed/

If you have a 2D char array, all the editing can be done in only a single row of text. This array only needs to have a few extra rows on each side of the visible text rows you see on-screen.

Adak 419 Nearly a Posting Virtuoso

sureshshan1292, in the spiral problem, you should be hearing warning sirens that your algorithm is too (low-level in the logic, explicit, or specific), and not abstracted enough. That is a LOT of code!

Are you still interested in this problem, or did you figure out what you wanted, already?

Adak 419 Nearly a Posting Virtuoso

Welcome to the forum, raj2raj! ;)

It's nearly always better to start your question in a new thread, instead of a "zombie" thread like this one, but anyway. Bucket sort is like you had 10 kinds of coins, in a mixed up pile, on the table, and you needed to sort them.

So you use 5 cups, one cup for each two denominations of coin. The coins are now "close" to being sorted, but not finished. Now you use another sorting algorithm, to finish off the sorting, within the cups. Insertion sort is commonly used since it's fantastic for close-to-sorted groups like this.

After each cup (bucket), has been sorted, all the coins are put back together again, in sorted order.

There are several ways to alter this algorithm into various "flavors" of a bucket sort.

A lot more info is here:

http://en.wikipedia.org/wiki/Bucket_sort

along with pseudo code, etc.

There are some horrid Insertion sort codes above your post, in this thread. Don't use them. Use this one:

void insertionSort(int a[], int lo, int hi) {
   int i, j, val;
   for(i=lo+1;i<hi;i++) {
      val = a[i];
      j = i-1;
      while(a[j] > val) {
         a[j + 1] = a[j];
         --j;
         if(j<0) break;
      }
      a[j+1] = val;
   }
}    
Adak 419 Nearly a Posting Virtuoso

Line 17 puts the needed end of string marker char, into place. Remember, chars are just a bunch of chars, UNTIL they have an end of string marker in place, after them.

bunch of chars: just a bunch of chars.
now a string: just one string.'\0'

It's confusing, because the end of string marker is not seen when the string is printed. It's ONLY a marker, not a part of the string.

As is, the code above is non-standard, because it uses conio.h for getch(), and clrscr(). Neither should be necessary or desirable. (used here, because the poster was stuck with the very old Turbo C compiler).

It also has a bug, since punctuation is not accounted for in the entered string.

it's inefficient, because it requires that strlen() repeats itself, over and over for the same word. Although this is just a beginner study program, that's a consideration, still.

Overall, it's a good starting point for a program, but needs more work.

Adak 419 Nearly a Posting Virtuoso

If you can use character code changes to effect this, that would be easier. This is a "roll your own" approach.

Think of a one-to-one translation, using an array. The letters and digits in the hex string, all have a value - A is 65, B is 66, etc. Of course, the digits have an integer value as well.

The hex values - whether letters or a digit, have a value that can be used. In this case, for the index of the translate[] array. translate['A'] (same as translate[65]), also has a value it holds. For this purpose, the translate[index] values will be assigned the corresponding values in Arabic.
This has to be assigned in your code, before anything else can be done.

Now it's just a matter of reading in the hex values, and assigning the corresponding values to the arabic string.

//you have char arabic[SIZE] and char translate[SIZE]

for(i=0; translate[i]!= '\0'; i++ )
arabic[i] = translate[i];

arabic[i]='\0'; /assign the end of string marker/

//and print out the arabic string with %s format in printf()

The warning here is that I know nothing about Arabic. If Arabic has no single letter or mark that translates into each letter of the hex string, then you'll have to adjust this algorithm, and possibly scrap it entirely. The digits should be no problem, since our digits are based on ancient Arabic numerals.

Adak 419 Nearly a Posting Virtuoso

What is the problem stopping you?

If you don't know how to multiply, sign up for a remedial math course, and drop programming for now.

If you thought someone would just happily do your homework for you, please think again. You learn nothing without working at it.

We HELP people with their program, we don't DO the program.

Adak 419 Nearly a Posting Virtuoso

Daniel honestly - you can think of a way to code up a loop and zero in on a square root of a number - I know you can.

Adak 419 Nearly a Posting Virtuoso

But it's NOT a contest for the shortest code - the length of the code is not the problem to be solved. Just keep it reasonable on the size.

The only problem really, is the speed. In my case, it wasn't possible because my compiler has a small default console buffer - so just getting the data, without any computations, was putting me outside the time limit.

Finally I learned 1) that the console buffer was indeed smaller, and had to be changed, and 2) how to change it.

After that it was not a problem, using the Sieve of Eratosthenes algorithm.

I don't believe you should be posting the answers (did it pass the test:
http://www.spoj.com/problems/TDKPRIME/
in a public forum however. Let people figure it out. If you want to discuss it, pass the test for this problem, and you can then go into the SPOJ forum, and discuss this problem, as much as you want.

Adak 419 Nearly a Posting Virtuoso

You ask for help, but we don't have the info from you, to help you. I know you don't want to spend the time to write up the specifics, but really, we have very little idea of what command does what, and how much, on your robot.

You haven't even described WHAT your problem really is, and what your changes have made in the performance of the robot, etc.

That's where forums that rely on written data, frequently can fail - it's a lot of work just to communicate the problem

But it must be done.

Adak 419 Nearly a Posting Virtuoso

Line 23, remove the & from that line.

rename struct temp tempSt, and make changes so it's clear which is which.

Adak 419 Nearly a Posting Virtuoso

This is an exact copy of another request I answered on another board - so I'd change it around to avoid suspicion of copying.

First, in get_file(DATE a). Change it from a void function, so it will return the DATE a, to the calling function:

DATE get_file(DATE a)  

//and the new last line:
return a;

Change the prototype of the function up near the top of the file, also, to match this.

Now you need to have a DATE struct to "catch" the DATE struct being returned. That should be done on line #52, above:

date=get_file(date);

The data was being read by the function get_file(), but it wasn't being returned.

Adak 419 Nearly a Posting Virtuoso

Because it's illegal in C. This has been answered for you in other forums already, in detail.

Adak 419 Nearly a Posting Virtuoso

Do NOT use feof() - it simply doesn't work the way a human thinks it should, and it will goof you up every time.

There are three ways:

1)

while((fgets(myCharArray, sizeof(myCharArray), filePointer)) != NULL) {
   //your code to work with myCharArray[], as you need to
   //fgets always puts a newline at the end of the array for you, space permitting
   //and NEVER overflows your char array. sscanf() is well suited to be used now.
}

2)

while((fscanf(filePointer, "%[^\n]", myCharArray)) > 0) {
   //similar to fgets() above. Reads and stores until the newline
   //as long as as it's able to read and store at least one object (not OOP though)
}

3)

int ok;  //NOT char, int!

while((ok=getchar()) != EOF) {
   //now you're forced to work at the char by char 
   //level, which is usually rather tedious
}

Overall, I'd use fgets() probably. It allows you to scan and find and parse our the char array as many times as you need to, very easily. Be sure to give it a generous size so you'll always have the entire line of text, + the newline + the end of string char: '\0'. To get rid of the newline at the end of the char array:

char *ptr = myCharArray;
ptr=strchr(myCharArray, '\n');
if(ptr)
   *ptr='\0';
Adak 419 Nearly a Posting Virtuoso

If you want to work with larger int's, move to a 64 bit system and compiler:

18,446,744,073,709,551,615 is the max integer (unsigned long long int)

Or use an array, and treat it like every element of the array, is a digit in a BIG integer. It is challenging, but not as hard to do as you might think at first.

Adak 419 Nearly a Posting Virtuoso

You'll have to recurse one time more than you want to, to find the next char, THEN if it's 'I' don't remove the 'b' you were checking out on the earlier depth. Otherwise, remove it.

Likewise, if you recurse one depth and find the end of the string, then don't remove the space or 'b' you're currently on.

Think of it just like a while() loop, but the recursive part of it, handles the "while" (the looping). The base case should be quite similar to the stop for a while loop.

VERY smart to use 'b' instead of an empty space (which is tough to work with in a visual sense).

Give it a try and see what you can come up with.

Adak 419 Nearly a Posting Virtuoso

Are you supposed to code up the sorter, or is using qsort() OK?

Adak 419 Nearly a Posting Virtuoso

The newline is indeed picked up by fgets(). If you think about it, the newline is THE thing that creates or defines a line of text, isn't it?

This will get rid of it:

//add to your include header list:
#include <string.h>   

//in your function where you are reading the lines of text:
char *ptr;

//read your line of text here
while(fgets(buff.... etc.) {
   ptr=strchr(buff, '\n'); //get the address of the newline at the end of the line (or null)
   if(ptr)         //if it was there - if space isn't available in buff[], it won't be there
      *ptr='\0';   //replace it with the end of string char
}

And you're good to go.

Adak 419 Nearly a Posting Virtuoso

Digits sort lower than any letters, so ascending order would start with 234bk... etc. Descending order is OK.

Normally, you'd want a separate function for sorting, but C also has qsort() as a very capable sorter.

Post up some code so we can see how the program is organized.

Adak 419 Nearly a Posting Virtuoso

That program was being used to solve a problem about the number of paths in a grid - which was quite large.

In their forum for the problems, it's customary to give the run time of the solution. Thanks for the timer.h info however. I can definitely use that.

Adak 419 Nearly a Posting Virtuoso

I don't mean to alarm you, but your program doesn't have a cost function. ;)

Adak 419 Nearly a Posting Virtuoso

This is what I use generally. There are newer timers available with higher resolutions, but this is all I need. I have identified the three lines of code for timing, with #0, #1, #2, and #3. You must have all four lines of code.

#3 line of code using the #define MACRO from time.h. Mine is called "CLOCKS_PER_SEC". That name changes from compiler to compiler. In Turbo C it was called "TICKS_PER_SEC". In Microsoft's compiler they have a slightly different name for it. Be prepared to look it up by reading the short file "time.h", or using the help that came with your compiler (or Google it).

This program is small and takes no measurable time, but it will show time used by a slower program. (It builds a Pascal Triangle, tilted to the left by 45 degrees, in case you're wondering.)

    #include <stdio.h>
    #include <time.h>                                            //#0
    #define SIZE 20

    int main(void) {
       int r,c,width,depth,size;
       unsigned long long int num;
       unsigned long long int pascal[SIZE*2+1][SIZE*2+1]={0};

       clock_t timer=clock();                                      //#1
       size=SIZE*2+1;
       width=size;
       depth=SIZE%2?SIZE:SIZE;
       for(r=0,num=1;r<size;r++,width--) { 
          for(c=0;c<width;c++) {
             if(r==0 || c==0) {
                num=1;
             }else {
                num=pascal[r][c-1]+pascal[r-1][c];
             }
             if(size<16) 
                printf("%4llu ",num);
             pascal[r][c]=num;
          }
          putchar('\n');
       }
       printf("\ndepth: %d\n",depth);
       //The triangle is rotated 45° left for easier creation, so
       //printing the answers for each depth, we traverse a diagonal, here.
       for(r=0,c=0;r<=depth;r++,c++) {
          //print out the center number (largest one), in each row
          printf("%d) %llu\n",r,pascal[r][c]);
       }

       timer=clock()-timer;                                          //#2
       printf("Answer is: %llu \n\n",pascal[depth][c-1]);

       printf("Elapsed time: %f\n",(double) timer/CLOCKS_PER_SEC);   //#3
       return 0;
    }
Adak 419 Nearly a Posting Virtuoso

Your array to hold the file's contents needs to be 2D (rows and columns): array[rows][cols].

Each time you want to save a row, copy it to array[rows] - that serves as the array pointer for that row. (In C, 2D arrays are arrays (rows) inside the larger array.)

The general technique is:

char *ptr;
char buff[256];
char array[20][256];  //20 rows, each 256 chars long
int row=0;
//where fp is your FILE pointer and has open the file already
do {
   ptr=fgets(buff, 256, fp);
   if(ptr) {                    //you have good data, not EOF
      strcpy(myCharArray[row],buff); //move the data - it's good
      row++;                    //set up for the next row
   }
}while(ptr);

This avoids putting a duplicate last line of data, (when EOF is reached), into the array, or just having a blank row.

Why is not a great question - many functions in C work with the format or parameters, inside the ():
printf(), scanf(), toupper, tolower() sqrt(), strcpy(), strcmp(), etc. Pointers are typically returned (scanf() for instance), or a number (printf(), strcmp(), etc.).

On line 18 of your code, remove the & from the printf(). That's for scanf().

Adak 419 Nearly a Posting Virtuoso

Actually, it's in Windows 7. Open a command window and type xcopy /? for all the info on it. Obviously, naming the files you want to move, and where you want to move them to, is critical.

That being said, I believe you'll enjoy programming it in C, instead, and learn something new in the process.

Adak 419 Nearly a Posting Virtuoso

Whatever you buy, buy something that you will want to use for a long time - robot type projects are not real cheap, and you will want to use it to DO stuff, not just be programmed one time, and sit in a box in the closet.

Look at what you want the robot to do - even if it's to teach you how to program a robot - and get the kit for the robot that best matches your wants and needs. Consider all the aspects of the kit before you get it - every robot I've seen has been designed to be good at some things, but terrible at doing other things. That's not a bad thing, but it means you need to do your research before you buy anything.

Did you register at a robot forum, yet?

harshi414 commented: thanx ! yes i have registered in a few froums but nothing useful ! +0
Adak 419 Nearly a Posting Virtuoso

There is no worse description of a probem than "it's just not right"! :(

Give a specific description and an example of the problem.

"Just not right" ---> WTF!

Adak 419 Nearly a Posting Virtuoso

Your robot will have to have a micro controller, if it is to be controlled by electronics. Since you "don't know about micro controllers", you will have to learn how to program them, because the controller (as the name implies) controls the robot, at a very low level.

We can't teach you, since it's not C - it's hardware, plus a hardware interface to allow the robot to send and receive messages.

I recommend you Google "robots forums", and find a forum that specializes in robotics. Robots are different, depending on their hardware and controllers.

How you program the robot depends on the controller, and the maker of the robot will include instructions on how to do that, for that particular make and model of robot. Some can use C as a user language, others use a variety of different langauges for the user to program their robot. They're not all the same in the choice of languages the user can work with. The last one I worked with had only languages of a special version of BASIC, or Pascal - no C.

Good luck!

ddanbe commented: Good answer! +14
Adak 419 Nearly a Posting Virtuoso

I don't fully understand the problem, but it sounds quite interesting. I went to codility.com, but they don't have their problems listed like some of the code challenge sites (Euler, Code Chef, SPOJ, etc.).

Adak 419 Nearly a Posting Virtuoso

You have an int array, and you have an array of int pointers? They are the same size, right?

Then it's straight forward:

Before you sort anything, you assign the address of the pointers to each array[index] number, in turn.

In your sorter, you will make all your comparisons using the array of pointers, to reference the ints. Whenever a swap is needed, you don't swap ints, you only swap the pointers addresses.

To print out the original int array, you simply print out the int array - nothing has been moved. To print out the sorted array of int values, you print out the values that are now pointed to be the array of pointers.

This is a similar bit of code, that uses an int array instead of an array of int pointers, but the logic is almost identical:

#include <stdio.h>

void printIt(int *a, int *map, int size, int type);

int main(void) {
   int i, j, temp;
   int a[]={3,8,0,4,1,2,6,9,5,7};
   int map[10];

   //initialize map
   for(i=0;i<10;i++)
      map[i]=i;

   //sort via Substitution sort
   for(i=0;i<10-1;i++) {
      for(j=i+1;j<10;j++) {
         if(a[map[i]] > a[map[j]]) {
            temp = map[i];
            map[i] = map[j];
            map[j] = temp;
         }
      }
   }
   printIt(a, map, 10, 0); //original order
   printIt(a, map, 10, 1); //sorted order
   return 0;
}

void printIt(int *a, int *map, int size, int type) {
   int i;

   if(!type) {
      printf("Original and current actual order in array a[]:\n");
      for(i=0;i<size;i++)
         printf("%2d ", a[i]);
   }
   else {
      printf("array a[] as enumerated with the map array as the index:\n");
      for(i=0;i<size;i++)
         printf("%2d ", …
Adak 419 Nearly a Posting Virtuoso

Check out fseek() to smartly maneuver around a file. Any time the records of the database are not fixed in their size, (that is, all the same size), you will find it more difficult finding your way around inside a file.

Conceptually, there is a tiny buffer, than can be used with ungetc(). Nothing is actually "put back" into the input stream, it's just put into the buffer, and a flag tells the next access to check that tiny buffer first. The actual implementation is left up to the compiler maker.

This is not a factual understanding, but my understanding of it. I'm sure you could Google and get better info.

Adak 419 Nearly a Posting Virtuoso

When you have a string of words - here a word, and then it's definition, on the same line, you want to use fgets() and put the entire line into a char array (I use "buffer", all at once.

The newline will be included on the end of the buffer (space permitting), so now using strlen(buffer) you can get the full size. Easy smeazy.

while((fgets(buffer, sizeof(buffer), filePointer))!= NULL) {
   //your other code in here
}

Remember to make buffer longer than any possible line of text, and you're good to go. A word, plus a definition, may be a line longer than 200 chars - so think 500 for starters.

Adak 419 Nearly a Posting Virtuoso

This is a 4 year old thread, so don't post your request here - start a new thread (don't be shy).

Also, we don't "pass code", we help you fix yours, if you have a problem.

Finally, you have to specifiy WHAT C program for a cluster server, you want? There are Linux distro's designed to work with clusters - why not Google that, and read up. You won't do anything nearly as good as they have, for a cluster operating system.

Adak 419 Nearly a Posting Virtuoso

Yes, working with the data inside an array is preferred. Once you start changing data in a file, it's really easy to muck up the file - and then garble the data.

The general technique is:

1) put the data into an array
2) change the data as you want - or mark it as "to be deleted". This might be changing a key number to 0, or -1, or changing the name string to "" or name[0]='\0'.

3) write out the data to a the data file, overwriting the old data.

For critical data, you'd write out the data to a temp file, check it for accuracy, and then remove the old file, and rename the temp file, to the regular data file name. Not necessary here, but having a backup file made first before any changes, would be good.

Adak 419 Nearly a Posting Virtuoso

To print in landscape mode, you can either use a printer feature, or a program like you're talking about, here.

If the printer has a landscape feature, then obviously you want to just send it the code to switch it into landscape mode. That feature is not available on all printers, and the code to activate it, if present, would not be the same for every printer. It should be in the owner's manual.

For a program, you'll want to bring the data you want to print into an array, and then rotate the array either 90° left or 270° to the right.

I have a program that does this rotation - but note that it only rotates arrays that can fit into memory. Larger arrays would need to be rotated in a "block by block" kind of algorithm.

Can you fit your data into one single malloc'd or global array? These are arrays created on the large "heap" memory space. An array created inside a C function is by default, created in a small stack of memory, and should not be used for this.

Looks like you're using FAR memory, so this is Turbo C/C++ with 16 bit compilers? Gruesome! As much as I liked turbo C/C++, it's days are LONG gone - free x32 or x64 C or C++ compilers are out there.

Edit: Now I'm confused - do you use FAR memory (addresses) on your compiler? I thought that was only 16 bit compilers that used it.

Adak 419 Nearly a Posting Virtuoso

Pare it down to a smaller memory size AND/OR enlarge the size of the page, if possible.

Without seeing the code, it's impossible to say more.

Adak 419 Nearly a Posting Virtuoso

The more common convention would be 1, 0, or -1. The standard may allow any value > 0 < 0 or 0 (as is seen with strcmp(), a very similar function).

The negative value in one, and the positive value in the other, is a problem however. Could it be that the sizeof(int) is different on these systems, when you print it out?