nucleon 114 Posting Pro in Training

(int)log10(n) + 1 will give you the number of digits.
You could strip digits off with a loop body like this:

digit = n % 10;
// store digit or whatever
n /= 10;
nucleon 114 Posting Pro in Training

You must use include guards. Do this:

#ifndef FILENAME_H_
#define FILENAME_H_
// header code here
#endif
nucleon 114 Posting Pro in Training

Yes, it should definitely be .h if it has no actual code.
Do you have include guards in your header files?

nucleon 114 Posting Pro in Training

I changed the structure. It's not a 3D array anymore, but a 2D array of RGB structures. So you access it like this: r = bufImage[im_x][im_y].r;

nucleon 114 Posting Pro in Training

Is this really what you want? #include "enum.cpp"

nucleon 114 Posting Pro in Training

Try this:

struct RGB {
    GLubyte r, g, b;
};

RGB **bufImg;

bufImg = new RGB*[height];
for (int i = 0; i < width; ++i)
    bufImg[i] = new RGB[width];
nucleon 114 Posting Pro in Training

Re-read my last post carefully.
In C it will NOT work.
In C++ it WILL work.
Here's a minimal program.
Compile it in C, then in C++ to see the difference. int main() { int i; &(i = 1); }

nucleon 114 Posting Pro in Training

This is you eighth post and still no code tags???

nucleon 114 Posting Pro in Training

If the grid is not too large, I would use a 2D array of car pointers as well as the linked list. Init the array to zeroes. When you choose a random position for a car, check that the position in the array is 0, then either store the car pointer there or pick another position (if it isn't zero).

nucleon 114 Posting Pro in Training

You put a backslash in front of the special character (the double-quote or the other backslash) in order to remove its specialness and simply display it as is. Try this: cout << "\"\\n\"" << '\n';

nucleon 114 Posting Pro in Training

In C, the assignment operator returns an rvalue.
In C++ it returns an lvalue, so your first example should work.
(Look up lvalue, rvalue if you don't know what they are.)

nucleon 114 Posting Pro in Training

Try something like this to see if it works:

#include <stdio.h>

char buf[1024];

int main() {
    unsigned i;
    FILE* f = fopen ("data.bin", "wb");

    /* Write exactly 2GB + 1MB */
    for (i = 0; i < 2 * 1024 * 1024 + 1024; ++i)
        fwrite (buf, 1024, 1, f);

    fclose (f);
}
nucleon 114 Posting Pro in Training

Not all COM methods return an HRESULT although most do. For the ones that don't, the object documentation should tell you what to check for to detect an error condition. With a BSTR return, it should be NULL on error (since it's a pointer).

nucleon 114 Posting Pro in Training

It sounds like GLUT may be easier than GDI(+).

nucleon 114 Posting Pro in Training

Looks more like a troll than a real post.

nucleon 114 Posting Pro in Training

Your compiler probably just warns you because it is not a good idea in general to name a function the same as one in the standard library.

nucleon 114 Posting Pro in Training

By "exit code" NicAx64 meant the code that the program returns to the OS.

Try writing a simple program that produces a file over 2GB and see if that works. Write OVER 2,147,483,648 (2GB) bytes. Compile it identically to your problem program. Does it work?

nucleon 114 Posting Pro in Training

This is a straightforward program to write with basic WinAPI functions. No MFC (that would be a waste of time unless you know it already) and certainly no OpenGL!
You can either use GDI or the newerGDI+.

NicAx64 commented: GDI and GDI+ now I just reading some tutorial about it. Just started ! +1
nucleon 114 Posting Pro in Training

You need to set the rankList pointers to NULL in Ranker's constructor.

You need to remove the ampersands in front of name in Competitor::print.

You should have destructors for Competitor and Ranker since they both dynamically allocate some storage.

And you don't need the (double) in this (and similar) lines: starters[0]->setTime((double)12.0); That's all I can see at a glance. Fix those and let me know if it works.

nucleon 114 Posting Pro in Training

And don't post a program with half the lines commented out. Remove them first to clean things up a little.

nucleon 114 Posting Pro in Training

In this case, perhaps IDE means Interactive Drawing Environment!
IDE usually means "Integrated Development Environment," such as Visual-C++.

nucleon 114 Posting Pro in Training

You need to use the /c option on cmd: psexec \\a19-00 cmd /c 'start www.google.com'

nucleon 114 Posting Pro in Training

You haven't said what's actually happening.
What is it doing wrong?
Is there any error messages?

nucleon 114 Posting Pro in Training

It would seem impossible for your original code (in post 1) to write more than width * height + 25 bytes (give or take a few bytes for different widths since you are writing these as text), so if you are getting 8 times this many bytes your problem must lie elsewhere. You need to attach your (minimal) program and data file.

nucleon 114 Posting Pro in Training

It's possible a malicious program is (imperfectly) hiding itself.

nucleon 114 Posting Pro in Training
test: dependencies
	shellscript_to_compile_thousands_of_files
nucleon 114 Posting Pro in Training

Yes. I threw some ints into it to show how to access it, but you can make Data whatever you need.

nucleon 114 Posting Pro in Training

You need to test string[count] != 0 in your while condition.
You need to increment count in your loop or you never look past the first character in string.
You probably want strchr, not strpbrk, and you won't want to simply assign it's return value to string[count].
strchr will return the address in chrset, call it p. Then chrset - p will be the offset that you wish to assign to string[count].

nucleon 114 Posting Pro in Training

Try something like this:

typedef int         Data;
typedef queue<Data> Queue;

vector<Queue> v;
for (int i = 0; i < nQueues; ++i)
    v.push_back (Queue());

for (int i = 0; i < nQueues; ++i)
    for (int j = 0; j < 5; ++j) // some data
        v[i].push (j);
nucleon 114 Posting Pro in Training

Try this:

test: dependencies
	gcc prog1.c -o prog1 ; gcc prog2.c -o prog2
nucleon 114 Posting Pro in Training

Similar to the other program, this bit is faulty:

if((ptr=fopen("hello.txt","r"))!=NULL)
 {
     while(!feof(ptr))
     {
       fstring[i++]=getc(ptr);
     }
 }

Try something like this:

if((ptr=fopen("hello.txt","r"))==NULL) {
     printf("can't open file\n");
     return -1;
 }
 int c;
 while((c = getc(ptr)) != EOF)
    fstring[i++]=c;
nucleon 114 Posting Pro in Training

This puts one extra character at the end.

while(!feof(ptr))
 {
  org[i]=getc(ptr); printf("%c",org[i]);
  i++;
  count++;
 }
 org[i]='\0';

Instread, try this:

int c, i = 0;
while ((c = getc(ptr)) != EOF)
    org[i++] = c;
count = i;

Also, try using the isupper() and/or islower() functions for the following part.

nucleon 114 Posting Pro in Training

Rename your memset function so it doesn't have the same name as the library function.

I don't know about the problem with printstr.

nucleon 114 Posting Pro in Training

It's a matter of where you want to store the object, and whether you wish it to remain in existence after the function in which it was created has returned.

What you are calling "static" allocation (more properly "automatic") saves the data on the stack. Dynamic allocation stores the data in the free store (a.k.a., the heap).

When data is stored on the stack, it disappears when the function that allocated it returns. By storing the data in the free store, you can return it from a function by returning its address, which will still be valid after the function's stack space is freed.

nucleon 114 Posting Pro in Training

Do you just mean something like this?

test: [i]dependencies[/i]
	gcc prog1.c -o prog1
	gcc prog2.c -o prog2
nucleon 114 Posting Pro in Training

If you need any doubles, they would be cents and total. You only need one loop, with an integer index counting the days. Take another stab at it and think it through step by step.

nucleon 114 Posting Pro in Training

In class TextField, lines needs to be a Field** And in TextField::TextField, line 5 should be lines = new Field*[num];

nucleon 114 Posting Pro in Training

Forget it. That probably won't help. It's best to post a compilable / runnable single-file piece of code if possible.

nucleon 114 Posting Pro in Training

Isn't a pbm a text file?
Shouldn't you be writing your numbers as text, with: writer << img_pix[i].rgbb[0];

nucleon 114 Posting Pro in Training

Try passing back by value (not reference) from operator=.

nucleon 114 Posting Pro in Training

You need to show your compiler and link commands.

nucleon 114 Posting Pro in Training

Also, organize your data into structs (if you are able/allowed).

nucleon 114 Posting Pro in Training

You need to declare the operationType in menu as a reference.
86 the asterisks.
Remove one tab from the beginning of every line.

nucleon 114 Posting Pro in Training

You're supposed to use code tags when posting code.
You'll need to show what you've attempted so far.

nucleon 114 Posting Pro in Training

The first step in a project is knowing what you want, and being able to explain it to others is a measure of that. However, with this thread and your previous thread I'm beginning to see what you mean.

You wish to simulate a CPU memory cache with a 64-bit wide datapath using a hashtable. It will hold 16K 64-bit words (the value) as well as the 64-bit address and last access time. The "8" dimension is for up to 7 collisions in the table?? With descriptive gold like this:

and the other is 8 ( which is the number of ways)

it's hard to tell.

And you wish to run this simulation on a 32-bit machine, which is why you're asking about a 64-bit structure? Something like this:

struct w64 {
    unsigned low;
    unsigned high;
};
nucleon 114 Posting Pro in Training

Try defining the argument variables (that you are setting in the if stmts and passing to the functions) at the top of the file, making them global:

int arg1;
int argArr1[22];
//...

This is not usually a good design, but if you are just trying to get it to work, and without any more detail (i.e., code), it's all I can offer.

nucleon 114 Posting Pro in Training

You've forgotten the [ ] around the array size in the initializer of p. Thus you are declaring p to point to a single double of value n. As you attempt to read memory past this first value you eventually get a segfault.

However, if you fix that problem, another will arise. You are asking to allocate 110,075,314,176 elements, each 8 bytes long, for a total of 880,602,513,408 or about 820GB. So unless you've got a terabyte of RAM you shouldn't run this program.

For that reason, a huge array is usually implemented as a "sparse array" (look that up).

nucleon 114 Posting Pro in Training

He's using a special header.

You do not want the semicolon at the end of the parenthesized portion of the if statement.

Other than that, it seems weird to be assigning y and z a constant value and then testing whether or not either are zero, which is what your code is doing.

nucleon 114 Posting Pro in Training

Why do you need a hash table? What does your memory model look like conceptually? What would the driver (main) look like, for example? You still haven't given near enough information.

nucleon 114 Posting Pro in Training

I'm not sure what you mean. What do you mean by "memory addresses and times for stores"?
What memory addresses? What stores?
What times? What loads?