Duoas 1,025 Postaholic Featured Poster

> The implication was there.
No, it wasn't. However, I can see how it could have been read as such. I will try to be more explicit in the future.

> Perhaps if you gave some examples that show your point more clearly.
The argv array is prepared by the startup code. You did not allocate it. Therefore, you cannot make assumptions on what data you are allowed to read near it. [memory you are allowed to read][memory you are not allowed to read] The quick brown fox...\0........READ.AND.CRASH...................... When you say memcpy( mybuf, argv[ n ], 50 ); you run the very real possibility that you will will try to read something that the processor will disallow, causing your program to fail. Granted, I don't know any PC where that will happen, but the point is that you are assuming something about implementation dependent architecture.

You should instead stick to reading only that which you are given: strncat( mybuf, argv[ n ], 50 ); This (or my previously proffered strncpy()) guarantees that you are not going to violate any memory restrictions, wrap segments, or do anything else that your particular processor may spring on you, because you know that you are not reading memory that does not belong to you. Just because you've been able to get away with it on a PC for years doesn't mean that you will be able to get away with it on some other computer, or even some future PC.

Duoas 1,025 Postaholic Featured Poster

The size variable is a variable. The compiler does not know what value it might hold at any given time.

Since you are using C++, you should be using a vector or deque for this instead of an array. But if you must use an array, just make one as big as the largest size you think you'll have, and make sure that it complains if size ever gets too large.

I haven't time to look very deeply at your code ATM, so if you are still having problems later I'll help then.

Duoas 1,025 Postaholic Featured Poster

> yes you are right but the 1000 th fib number is too big to make calculations or store
Er, if you are playing with Fibonacci numbers surely you are using some sort of bignum library?

Duoas 1,025 Postaholic Featured Poster

Alas, I've never had much patience for video tutorials. The ones at ibiblio are usually okay but I haven't spent much time looking through them.

If you really thing a tut is a good idea I can cobble one together sometime within the next week or so, or at least link to some good ones I can find that do what I did.

I don't know if you remember or not, but Waffler did his "Pink Girl" 2D sketch and I thought it would be fun to model and rig. So we both (and I think one other) did a bunch of pink girls. I tried to get everything to look as cartooney as the original, but cipix and a few others modified my facial textures to be more pen-and-ink-ish. But I think my pink girl was the only one that was ever fully rigged. She's only slightly more complex than Billy though... The arms and legs are wobbly tubes (rigged with IK chains) in both.

Both the files can be downloaded and you can look at the UV mapping in them.

Duoas 1,025 Postaholic Featured Poster

To calculate Fibonacci numbers you don't need a lookup table... Remember, each successive term is the sum of the previous two. Hence, you only need to remember two numbers at a time. Use a loop to find the nth term you want.

if n == 0 return 0
if n == 1 return 1
prev = 0
curr = 1
for i = 2 to n:
  temp = prev + curr
  prev = curr
  curr = temp
return curr

This is fairly quick for terms under several hundred thousand...

If you want to get fancy, you can use something of a modulo table to store the prev and curr for every 1000th term or something, just to keep calculation times down if you are calling your Fibonacci function fairly often.

Hope this helps.

[EDIT] too slow again...

Duoas 1,025 Postaholic Featured Poster

Are you talking about that Billy model in "Action Constraints Made Easy" or Waffler's pink girl?
I don't think I did anything particularly amazing in either one... (or maybe you are thinking of someone else?)

Hmm... I did spend some time on Billy's shoes...
There is a tutorial (in the tutorials section) that helped me a lot about properly unwrapping a face and head. The real trick is to select only the faces that define the shape first, LSCM, adjust, pin, select more faces, repeat...

/me goes to figure out what I did

Duoas 1,025 Postaholic Featured Poster

There's a blurb over on WikiBooks about entering protected mode. I've never done it (nor do I care to) so I know nothing about it. However, if you are not doing all of the things listed there your pc will decide that something is horribly wrong and reboot.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Heh, yes, so it is. I meant atoi().

Duoas 1,025 Postaholic Featured Poster

No...
How exactly did you get an icon into the system tray to begin with?

Duoas 1,025 Postaholic Featured Poster

I never said memcpy() wasn't standard. Only that strncpy() was also.
The difference in choice is this: do you own/did you allocate the memory you are accessing? If not, you may very well be playing with fire to try reading (or writing) past the end of memory you have not allocated.

The strncpy() function always pads the target out to n bytes. However, it stops reading the source when it hits the end of the string, which the C specification guarantees to be there in argv[].

You are correct about watching the end of string, as strncpy() does not guarantee that the target is null-terminated.

I will agree that the use of strncat() is the best choice so far, since it addresses both issues nicely.

The strtol() has the same validation problems as stroi(). Just because it returns something different... But you are right in that it is a little more convenient for catching incomplete conversions...

Cheers.

Duoas 1,025 Postaholic Featured Poster

Not sure I understand. If I use getTruckInfo(), there will be no point for overloading the istream, correct?

Exactly. The >> operator is for doing input, nothing else. Google "C++ serialization" for more information.

When you overload any operator to do something different than its primary function (or, in this case, something directly opposite its primary function) you are asking for trouble. Its like overloading ++ to do some power series expansion or some such. Just don't do it. You are always better off creating a method with a name that explains what it does.

You may say, "well, I know what I am doing" or "I'm the only one using the class" or "It's just some dumb homework" or something like that... but computer models only work when followed. Even in this short example you made an error as a direct consequence of breaking the mold: "Owner: Name:". Had you not overloaded Person's >> to do something weird, your code would have worked as expected.

I am not too fond of school environments that let people get away with such stuff because it has the same corrosive influence on the student's programming ability as the spaghetti code that BASIC encouraged.

Hope that makes sense.

[EDIT]
Oh yeah, there is no need to write a method for every field in the object. Just do what you were trying to do in the >> operator: ask for each piece of information in turn and return …

Duoas 1,025 Postaholic Featured Poster

Close. Remember, 6 doesn't evenly divide 100: if (((num - 100) % 6) == 0) cout << endl; Hope this helps.

Duoas 1,025 Postaholic Featured Poster

How did you add it? (Did you use some component you got off the web or did you use the Shell_NotifyIcon function?)

Changing the icon is simply a matter of using NIM_MODIFY with a different icon handle in the hIcon field of the same NOTIFYICONDATA record you first used to put the icon there to begin with.

If it was some component check the documentation...

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

> PS: memcpy is safer
No it's not. It will try to copy n characters whether it hits an architecture-dependent read boundary or not. Use strncpy(). It is fully standard and stops in the right place.

To convert a string to an integer #include <cstdlib> and use the atoi() function: int i = atoi( "42" ); Also, this is the C forum. If you plan to use C++ please post in the C++ forum. While the same people frequent both, the advice you get will vary depending on the language. (C and C++ are significantly different languages.)

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

I hope that your struct was just missing the element part:

typedef struct [B]element[/B]
{
  int data;
  struct element *next;
} node;

You aren't likely to compile properly if you use struct element without first tagging it...

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Your errors are not invincible, but they are all due to a very bad mixture of I/O (sorry).

You'll need to trace your program (using a piece of paper and pencil) to see what is happening.

Firstly, don't use output methods (cout, etc.) inside an overloaded input operator (>>). That is just bad design no matter how you look at it. Yes, I know it can be done, but it breaks every model there is, and will lead to future failures. Use instead a named method like getTruckInfoFromUser() or somesuch if you plan to use both input and output methods together. Don't disguise them both under the pretense of only one.

The mixup with "Number of cylinders: Owner: Name:" has to do with your use of these overloads. (After number of cylinders you never use <<. You cout "Owner:" then send off to Person's overloaded >> which couts "Name:". And you use a mixture of getline() and >> and ignore(). While not necessarily a problem, pick one --preferably only the one matching your operator.)

I hope you don't feel I've been unnecessarily harsh... but this really is industrial strength advice, and if you fail to heed it it really will bite you, and hard, later. Change your operators to named functions; only then mix and match input and output as you please. If you use getline() to get strings you won't need to use ignore() and you will avoid user input errors that can mess-up your …

Duoas 1,025 Postaholic Featured Poster

Use [[i][/i]code[i][/i]] tags please.

First, watch your syntax. Any time you have a ; you are terminating a statement. So Animal *M;= new Animal(); is two separate statements: Animal *M; and = new Animal(); .

The first 'redeclares' the variable M. The second is error. What you want to say is M = new Animal; Secondly, watch your delete statement. Use one per object. delete M; delete C; etc.

Lastly, don't forget to declare your constructor and destructor. Your compiler may let you get away with just defining them, but that's not standard C++.

class Zoo {
  ...
  public:
    Zoo();
   ~Zoo();
  };

Zoo::Zoo() {
  M = new Animal;
  }

Zoo::~Zoo() {
  delete M;
  }

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

You need to consider the format of your input. I will presume something like

Avery Brown
129 Landis St.
Chapel Hill, NC 01234
555-1234
Emma Green
13 Rabbit Run Rd.
Chapel Hill, NC 01234
555-2933

Every four lines is a different record. So read one whole record at a time (that is, read four lines at a time [as per my example, or however many lines per record you are actually working with]).

So, some pseudo might be:

get phone number from user
do
  get record from file
  if eof then complain and quit
while phone number from file doesn't match phone number from user
print entire record

Also, make sure you get a good reference. There is no such function as is_open(). You can test success directly from the object:

ifstream AB( "AddressBook.txt" );

if (!AB) {
  cerr << "I couldn't open the file 'AddressBook.txt'." << endl;
  return EXIT_FAILURE;
  }

// file is fine, ask user for phone number and do while loop go here

AB.close();

// print record found or tell user that record was not found

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

No segment registers are involved. The m address following the opcode is a direct, linear address. (It has to be for the purpose to which these opcodes are designed.)

What's cr0?

Duoas 1,025 Postaholic Featured Poster

:icon_lol: Yeah, a lot of beginning-programming teachers are like that.

Glad to be of help. :icon_cheesygrin:

Duoas 1,025 Postaholic Featured Poster

Er, sure I have time for one more...

Don't use system("pause"); . Tell your professor it is evil and non-portable and he shouldn't be teaching it. If he gives you a hard time tell him people who know better than he know better. (Yes, I know that sounds non-sequitur, but he should know better either way.)

If you must, use while (cin.get() != '\n'); instead.

Now for your problem.
Make your calcScore() function take an argument: double calcScore( Stat s ); Then you can pass the Stat object you created in main() to the function to calculate the score instead of creating a new, useless Stat object in the function itself. Also, the function should return a value, not print anything.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Are you doing this for school or just for your own learning?

You are the one who asked about system("pause"); in your second post. How is it you are writing a command-line application and not know what the command line is or how to access it? Go hit your teacher over the head.

Duoas 1,025 Postaholic Featured Poster

Ehem...

Do one of the following:

1. Tell your IDE that you are compiling a console application --it should be smart enough to wait for you to read the console before the window disappears. If it can't do that:

2. Run your program from the command prompt. Or.

3. Use while (cin.get() != '\n'); instead of system().


[EDIT]
Yoinks...

I just tested your code and it works fine for me.

You might want to put a PrintArray() after you GenerateArray() just to see what the generated array was before printing out information.

Also, don't forget spacing and newlines in your output. For example, in sumArray() you should have: cout << "The sum of the matrix is " << sum << endl; And stick that while loop I gave you before the return statement in main().

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Since my last post I've been looking around the web to see what I can find out. According to Peter Below (the guy who designed the rich edit stuff in Delphi), you will need to find a unicode rich edit component. [ 1 ]

There appears to be a lot of hubbub about tRichView , which has a trial version, but is not free.

If you don't want to pay money, you'll have to search more than I or roll your own. You can create a unicode rich edit component by using CreateWindowEx() with the appropriate class name (RichEditW, I think), and handle all your own messages. A rich edit control isn't that difficult to handle, just a lot of calls to sendMessage() and a couple message handlers.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

I'm always just a little taken aback by things like getch(); and system( "pause" ); stuck in people's code. It is non-portable and in the case of getch() and cin.get(), leaves the input in an indeterminate state. Since the standard input is line bufferered, the most robust code would be something like: while (cin.get() != '\n'); ...which would read and discard anything typed until the ENTER key is pressed.

Even so, IMAO you shouldn't need to put such things in your code... The IDE should be able to do it for you or just run it from the command line as it was designed...

/me puts soapbox away

Duoas 1,025 Postaholic Featured Poster

I honestly don't remember that much about it... and you can google the info just as well as I can.
You have to gather information about video capabilities and single/dual window addressing before doing anything anyway... The table of function pointers is stored in the same place as far as I recall...
I don't think there is any advantage to using a far ptr function over an interrupt function.

Alas.

Duoas 1,025 Postaholic Featured Poster

Look, I can't give you any more information than I've got. Here's what the manual says:

The LGDT and LIDT instructions load a linear base address and limit value from a six-byte data operand in memory into the GDTR ar IDTR, respectively. If a 16-bit operand is used with LGDT or LIDT, the register is loaded with a 16-bit limit and a 24-bit base, and the high-order eight bits of the six-byte data operand are not used. If a 32-bit operand is used, a 16-bit limit and a 32-bit base is loaded; the high-order eight bits of the six-byte operand are used as high-order base address bits.

The SGDT and SIDT instructions always store into all 48 bits of the six-byte data operand. With the 80286, the upper eight bits are undefined after SGDT or SIDT is executed. With the 80386, the upper eight bits are written with the high-order eight address bits, for both a 16-bit operand and a 32-bit operand. If LGDT or LIDT is used with a 16-bit operand to load the register stored by SGDT or SIDT, the upper eight bits are stored as zeros.

LGDT and LIDT appear in operating system software; they are not used in application programs. They are the only instructions that directly load a linear address (i.e., not a segment relative address) in 80386 Protected Mode.

SGDT/SIDT copies the contents of the descriptor table register to the six bytes of memory indicated by the operand. The LIMIT field of the register …

Duoas 1,025 Postaholic Featured Poster

If you are using the (ancient, obsolete) TurboC, then you have access to functions like clrscr(), and gotoxy(). With other windows compilers, though, you are unlikely to have them... The Wikipedia article lists all the functions from conio.h you are likely to have on any given windows compiler. If you are using an MS compiler, you might have something like _clearscreen() or somesuch...

You could, like Ancient Dragon said, play with the Windows Console functions, which aren't that difficult (SetConsoleCursorPosition()), but require a bit of reading.

I still recommend using pdcurses. It is truly cross-platform and avoids having to play with callback hooks...

[EDIT]
Actually, now that I'm awake... Hasn't your professor given you any instruction on how to interface with the console? Seems an odd assignment without giving you some instructions on how to read arrow key presses and position the cursor on the screen...

Duoas 1,025 Postaholic Featured Poster

It is unfortunate, but I don't think the Delphi tRichEdit class can do unicode. The lines member is a tStrings object, which uses the string type instead of wideString.

I use Delphi 5.0 and I've been playing around with the rich edit control myself for the past week or so... The tRichEdit component is woefully underpowered. You need to do a lot of stuff yourself.

If you can wait a few days I'll post an example that I think will help you out a lot (well, at least to get you started).

In short though, you'll need to include the RichEdit unit (yes, I know it isn't in the docs) and communicate with the rich edit control yourself using sendMessage. Also, the Win32 Programmer's Reference (win32.hlp) that comes with Delphi is a very useful reference, though not always complete or correct, alas.

You can add input languages from Start --> Settings --> Control Panel --> Regional and Language Options. On the "Languages" tab press "Details" and add the language you like. Thereafter there will be a little button on your taskbar to switch keyboard layouts. Make sure you look up the new layout before switching though...

Other than that, Google is the only other help. Look for things like "rich edit syntax highlight" for the most useful information. Be sure to look through all the Delphi pages too... there are random snippets to do unusual things with a tRichEdit here and there. Unfortunately, you'll still …

Duoas 1,025 Postaholic Featured Poster

interfacing with the console
If on Windows you'll have to use the (non-standard) stuff in <conio.h>. Just include the library file and compile.

If on linux you'll have to use the curses library. There are various versions of it: curses, ncurses, and pdcurses. You are sure to have at least one of them. To compile a program using the curses library you need to do something like: g++ -o myprog myprog.cpp -lpdcurses (assuming "pdcurses", of course). If you have more than one version of curses, choose pdcurses over ncurses over curses... In all cases, include the file <curses.h> in your code. Get documentation on the internet, or at the school terminal prompt by typing "man curses".

Don't try to get around curses. Raw input from the keyboard is not always friendly. The curses library makes it friendly.

memory layout
There are two common ways to store textual data. I recommend you stick with a linked list of lines. That is how vi does it. (The other method is to have the entire file stored in one giant buffer, and the stuff on screen copied over into a smaller editing buffer. This is how emacs does it. There is nothing wrong with this method, but it requires some careful bookkeeping you can avoid for a simple assignment.)

example
Here is a simple example for you:

#include <curses.h>

int main() {
  // Initialize the curses library
  initscr();
  raw();
  (void) noecho();
  nonl();
  intrflush( stdscr, FALSE …
Duoas 1,025 Postaholic Featured Poster

Oh yeah, you don't have to pay VESA anything to use the functions. Now if you download software from them or attempt to duplicate their code or specification that may be different...

The whole point of VESA was to provide a single standard for interfacing with an SVGA. Before VESA organized, if you wrote a program or game or anything that used SVGA features you had to provide a driver for every type of SVGA card you could imagine your user having. Remember all those old DOS games that came in 2K of files and had 15K of drivers?

Duoas 1,025 Postaholic Featured Poster

One of the lovely things about C...

Check line 5 of changeSetting(): you've got the ; on the wrong side of the }.

Every single statement in C must be terminated by a semi-colon. It's the little things that get you...

Duoas 1,025 Postaholic Featured Poster

This is why you need to find a reference. There isn't any m16 or m32, only an m, which is stored in the three or four bytes that follow the opcode and ModR/M byte.

Since these are protected-mode ops, the operand-size and address-size bit is stored in the D flag of the executable segment descriptor.

So in memory, the SGDT code looks like 0F 01 00 lo md hi 00 (offset is "hi md lo" [your m32])
or 0F 01 00 lo ml mh hi (offset is "hi mh ml lo" [your m16])

These opcodes are really only useful for writing operating system software. What exactly are you trying to do?

Duoas 1,025 Postaholic Featured Poster

That's because in main() you defined value as an int, not an array. But you are treating it like an array.

Forget the array. Look over your class notes and textbook and stick the scanfed number in your linked list. Don't forget to make functions to add a node to the linked list like I asked you.

Also, watch your indentation and formatting. The for statement takes one statement following. If you want to have it take more than one then you must use { and }.

Think about it and post back later.

Duoas 1,025 Postaholic Featured Poster

That's just the compiler's obnoxious way of saying that you declared a method named TitledEmployee::setTitle but didn't define it anywhere.

What compiler are you using, BTW?

Duoas 1,025 Postaholic Featured Poster

Beh, I'm feeling extra generous right now so here's how to traverse the linked list.

void print_list( node_t node )
  {
  printf( "The linked list:\n" );
  while (node != NULL)
    {
    printf( "%d\n", node->value );
    node = node->next;
    }
  printf( "done.\n" );
  }

You can print your list with: print_list( head ); Have fun now.

Duoas 1,025 Postaholic Featured Poster

A linked list node always looks like this:

typedef struct tag_node {
  int value;
  struct tag_node *next;
} node_t;

The value itself may be any type of thing, even though in this example I used an int. Also, you could have more than one value in each node. You could also have a pointer to the previous node for a two-way linked list. (If you wanted to make a binary tree you would have two "next" pointers, one to the A branch and one to the B branch. Etc.) The last node in the list has a next value of NULL.

Playing with linked lists is a little bit tricky. You have to think about how to insert, append, and delete nodes. Each operation deserves its own function.

Oh yeah, the list "head" pointer has the following type: node_t head; Hope this helps.

Duoas 1,025 Postaholic Featured Poster

That's because you've got it buried in the Employees namespace. Use its full name: Employees::TitledEmployee frank; Have fun.

Duki commented: Thanks for the C++ help! +4
Duoas 1,025 Postaholic Featured Poster

Yes, like I said in my first reply, you'll need to do some work on your own.

By that I meant work thinking about the code. Working by trying to find the answer for you online is just wasting your time and teaching you nothing. Seriously. You won't get past the semester unless you understand basic things like loops and simple I/O. You'll spend more time trying to get around it and have a bigger headache than if you just do it straight.

Work at it. If, after five efforts to make it work fail, give us some code and your compiler errors or output errors and we'll be glad to help you.

Duoas 1,025 Postaholic Featured Poster

Yoinks, iamthwee, at least she is asking to learn...

This is an expression: x > y . It evaluates to an integral (aka ordinal) value (specifically, a bool), which is what the switch statement takes. So when you say switch (something) { as long as something evaluates to an integral expression then the switch will work just fine.

Nobody uses switch for boolean expressions because it is faster and easier to read just to use an if. The if, btw, also takes an integral expression. If zero, it is understood as false. If non-zero, it is understood as true.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Sure. Boolean is an ordinal type.

switch (x < y) {
  case true:
    // hmm, x < y
    break;
  case false:
    // wait, x >= y
  }

[EDIT] man, too slow again...

No prob DREAMER546 :-)

Duoas 1,025 Postaholic Featured Poster

Both should work.
Personally, I prefer to use lots of parentheses to make it obvious (both to myself and to the compiler) what exactly I mean to say:

cout << (
  (grade == 'A') ? "excellent" : (
    (grade == 'B') ? "very good" : (
      (grade == 'c') ? "good" : "not so good at all" )))
  << endl;

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

This is deliberately obfuscated code. Where did you get it?

Salem commented: Certainly looks like it to me. +11
Duoas 1,025 Postaholic Featured Poster

Look, I'm sorry, but I've got a bit of a headache right now. Please format your code and stick it in code blocks.

[[i][/i]code[i][/i]]
int main() {
[[i][/i]/code[i][/i]]

becomes:

int main() {

If you (nor anyone else) can read the code, it is probably wrong...

Duoas 1,025 Postaholic Featured Poster

It looks to me like you are mixing too many types.

To read a row of characters just read in a string

var s: string;
begin
writeln( 'Please enter a sentence:' );
readln( s );
...

The words function should take some arguments instead of using globals:

type tStrArray = array[ 1..MAX ] of string;

// Split s into words. Store the words in sa. Return the number of words stored.
function words( s: string; var sa: tStrArray ): integer;
  var
    i:    integer;
    temp: string;
  begin
  result := 0;  // number of words found

  for i := 1 to length( s ) do
    if s[ i ] = ' '
      then begin  // add the found word to the list
           if temp = '' then continue;
           inc( result );
           ss[ result ] := temp;
           temp = ''
           end
      else temp = temp +s[ i ];  // still finding the word

  if temp <> ''
    then begin
         inc( result );
         ss[ result ] := temp  // don't forget the last word...
         end
  end;

So now, you can say:

const
  MAX = 100;
type
  tStrArray = array[ 1..MAX ] of string;
var
  s: string;
  strarray: tStrArray;
  number_of_words: integer;
begin
writeln( 'Please enter a sentence:' );
readln( s );
number_of_words = words( s, strarray );
...

You'll have to continue from here. Next sort your list of strings. A bubble sort ought to do. Then use a loop to print your list of strings.

If this is homework, and if you …

Duoas 1,025 Postaholic Featured Poster

You haven't used [[B][/B]code[B][/B]] tags so I can't tell exactly what you were thinking when you wrote this, but your problem is with your for loops and indentation. Whenever you make something, always indent to show yourself which statements belong to another statement. If more than one statement is indented under another, then you need to use { and }.

In your main function, you have (properly indented):

int main()
{
  ... // stuff skipped here

  for (row=0;row<3;row++)
  {
    for (col=0;col<3;col++)
      printf("Division inventory value=%lf\n", product[col]);

    system("PAUSE");
    return 0;
  }
}

You can see that the call to system and return belong to the outer for loop, which is not what you wanted. Since product is a 1D array, you don't actually need two loops, so go ahead and delete lines 5, 6, and 12, and unindent 7..11 by two spaces.

You have a similar problem in matrix_vector.

void matrix_vector(int row, int col, int stocks[][NO_OF_PROD], double cost[], double product[])
{
  int i, j;
  for(i=0;i<=row-1;i++)
    product[i]=0.0;
  for(j=0;j<=col-1;j++)
    product[i]+=stocks[i][j]*cost[i];
}

You need lines 5, 6 and 7 to belong to the loop on line 4, but currently only line 5 does. Indent 6 and 7 a couple of spaces and place a { between lines 4 and 5 and a } between lines 7 and 8.

Other than these simple syntactic errors you seem to be thinking out the problem very well.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Sure, you can use whatever you like. Once created they look very much the same...

I thought your professor had given you a function named printVectorOfVector(). But if I understand you correctly, you've got to write the code for that function?

Use two nested for loops: the outer iterating through the rows (0..2) and the inner iterating through the columns (0..2). In the center assign each element[ row ][ col ] a random value using the method in the link I gave you.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

The code -a is a unary operator, so he isn't trying to do anything weird.

The argument to your operator function should be a reference: zz operator - ( zz &z ) Otherwise it looks fine.

Duoas 1,025 Postaholic Featured Poster

You need to find yourself a good reference. I recommend Ferraro's Programmer's Guide to the EGA and VGA Cards. It's a bit out of date but all the info you need is there.

To set a bank use something like:

mov ax, 4F05  ; VESA function:
mov bh, 0     ; set bank window
mov bl, wnum  ; window number (0 or 1)
mov dx, bnum  ; bank number (depends on granularity)
int 10h

The bank number is of course dependent on your card's granularity, which you must look up with the appropriate function.

The window is simply the part of video memory accessed when you read or write to the host's video access memory. Many SVGAs have the ability to do "single" or "dual" mode access. That is to say, you can have a different part of video memory addressed when reading and writing. I think that all SGVA cards can do single window access, but I'm not sure about that. (It is another thing that you should set-up in your initialization).

If all this went over your head, you need to get a good reference and read it hard.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

You'll have to give an effort yourself first. You'll have to create a function that takes as argument a 2D vector: void fillVectorOfVector( vector< vector<double> > &v ) The code in printVectorOfVector() should help you there.

To generate random numbers see here.

Post again with what you come up with, and any error messages you get.