279 Posted Topics

Member Avatar for toadzky
Member Avatar for toadzky
0
194
Member Avatar for carlosrowlett

The usual approach here is to "shuffle" the numbers and then pick them off one by one. (Code untested.) [code] // Load array for (int i = 0; i < 40; ++i) n[i] = i + 1; // Shuffle for (int i = 39; i > 0; --i) { // …

Member Avatar for nucleon
0
83
Member Avatar for losh177

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

Member Avatar for losh177
0
229
Member Avatar for Icebone1000

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

Member Avatar for nucleon
0
209
Member Avatar for Hiroshe

[icode](int)log10(n) + 1[/icode] will give you the number of digits. You could strip digits off with a loop body like this: [code] digit = n % 10; // store digit or whatever n /= 10; [/code]

Member Avatar for Hiroshe
0
171
Member Avatar for sheff21
Member Avatar for caperjack
0
332
Member Avatar for daviddoria

Try this: [code] struct RGB { GLubyte r, g, b; }; RGB **bufImg; bufImg = new RGB*[height]; for (int i = 0; i < width; ++i) bufImg[i] = new RGB[width]; [/code]

Member Avatar for Narue
0
312
Member Avatar for sarawilliam
Member Avatar for bancje

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).

Member Avatar for bancje
0
102
Member Avatar for bussaina
Member Avatar for sarawilliam

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

Member Avatar for sarawilliam
0
924
Member Avatar for pagu

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?

Member Avatar for nucleon
0
108
Member Avatar for deadmancoder

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

Member Avatar for NicAx64
0
224
Member Avatar for gsingh2011

Rename your [b]memset[/b] function so it doesn't have the same name as the library function. I don't know about the problem with [b]printstr[/b].

Member Avatar for nucleon
0
422
Member Avatar for tendolm

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 …

Member Avatar for tendolm
0
308
Member Avatar for eviocg

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

Member Avatar for nucleon
0
135
Member Avatar for Hiroshe

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 …

Member Avatar for Hiroshe
0
101
Member Avatar for homeryansta

Try something like this: [code] 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); [/code]

Member Avatar for homeryansta
0
136
Member Avatar for bluebird

Similar to the other program, this bit is faulty: [code] if((ptr=fopen("hello.txt","r"))!=NULL) { while(!feof(ptr)) { fstring[i++]=getc(ptr); } } [/code] Try something like this: [code] 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; [/code]

Member Avatar for nucleon
0
92
Member Avatar for bluebird

This puts one extra character at the end. [code] while(!feof(ptr)) { org[i]=getc(ptr); printf("%c",org[i]); i++; count++; } org[i]='\0'; [/code] Instread, try this: [code] int c, i = 0; while ((c = getc(ptr)) != EOF) org[i++] = c; count = i; [/code] Also, try using the [b]isupper()[/b] and/or [b]islower()[/b] functions for the …

Member Avatar for nucleon
0
116
Member Avatar for Emerald214

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 …

Member Avatar for nucleon
0
101
Member Avatar for nexocentric

Could you do something like this: [code] scanf( " " ); // Consume whitespace, if any (incl. newline) fgets( ... ); [/code]

Member Avatar for Ancient Dragon
0
495
Member Avatar for cassie_sanford

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

Member Avatar for VernonDozier
0
2K
Member Avatar for gsingh2011
Member Avatar for sid78669

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

Member Avatar for sid78669
0
455
Member Avatar for yangty152
Member Avatar for onlymsfrance

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

Member Avatar for WaltP
0
80
Member Avatar for ellimist14
Member Avatar for nucleon
0
153
Member Avatar for nuclph

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

Member Avatar for nucleon
0
80
Member Avatar for wonder_laptop

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 …

Member Avatar for Lerner
0
125
Member Avatar for colmcy1

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: [code] int arg1; int argArr1[22]; //... [/code] This is not usually a good design, but if you are just trying to get it …

Member Avatar for Narue
0
138
Member Avatar for lehe

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 …

Member Avatar for nucleon
0
189
Member Avatar for wonder_laptop

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?

Member Avatar for wonder_laptop
0
87
Member Avatar for Ψmon

MyStudent.Name is the name of a storage location capable of holding up to 20 characters (including the terminating null character). You cannot simply assign a string constant to MyStudent.Name since that just tries to copy the [b]address[/b] of the string constant to MyStudent.Name. What you need to do is copy …

Member Avatar for Ψmon
0
168
Member Avatar for Max721

Sleep a day at a time. Check the date/time every time you wake up.

Member Avatar for nucleon
0
103
Member Avatar for cwarn23

Have you tried [url=http://www.winprog.org/tutorial/]theForger[/url]? Also note that [url=http://msdn.microsoft.com/en-us/library/default.aspx]MSDN[/url] (Microsoft Developer Network) has full windows documentation and a [url=http://msdn.microsoft.com/en-us/library/aa383668(VS.85).aspx]generic sample application[/url] as well as a [url=http://msdn.microsoft.com/en-us/library/aa383686(VS.85).aspx]categorized list[/url] of API (Application Programmer Interface) functions. There is also [url=http://msdn.microsoft.com/en-us/library/d06h2x6e.aspx]MFC[/url] (Microsoft Foundation Classes), an object-oriented wrapper for the API, but you should probably learn …

Member Avatar for mitrmkar
0
143
Member Avatar for ellimist14

When you swap elements in the salesID array, swao the corresponding elements in the other arrays.

Member Avatar for siddhant3s
0
114
Member Avatar for power_computer

This deactivates the close option. Remember that you'll have to catch ctrl-C too. [code=cpp] #define _WIN32_WINNT 0x0500 #include <windows.h> int main() { HWND hwnd = GetConsoleWindow(); HMENU hmenu = GetSystemMenu (hwnd, FALSE); HINSTANCE hinstance = (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE); while (DeleteMenu (hmenu, 0, MF_BYPOSITION)) ; system ("pause"); } [/code]

Member Avatar for nucleon
0
1K
Member Avatar for iTsweetie

In C++ this problem would usually be solved using a [b]string[/b] and a [b]map[/b]. Is there any reason you're not using these? If you must use strtok and do not want to copy the tokens it finds but instead just point to them like you are trying to do, you …

Member Avatar for nucleon
0
78
Member Avatar for skitzo315

Even though you store it in a double, you are still doing integer division because both operands to the slash are integers. Add a decimal point to at least one of them to get decimals. [icode]value = 1.0 / 2;[/icode]

Member Avatar for siddhant3s
0
90
Member Avatar for sonicstage

Start by reading the code you've been given carefully and try to understand it (it would be too tedious to explain it here; consult your textbook). Then write a piece of the implementation (e.g., initialize the cave) and test it. Then write the next piece. Note that the cave is …

Member Avatar for nucleon
0
201
Member Avatar for lllllIllIlllI

In the standard "16.2 Source file inclusion" (my first reference!) it mentions an interesting difference between <header.h> and "header.h". Basically, it says that the "" form may not even be supported, and if it isn't or if it is but the file is not found using that method, then it …

Member Avatar for lllllIllIlllI
0
239
Member Avatar for lostinC
Member Avatar for nucleon
0
137
Member Avatar for nexusdarkblue

Try moving your definition of [icode]flight schedule[][/icode] to the beginning of main.

Member Avatar for nucleon
0
240
Member Avatar for Gagless
Member Avatar for Gagless
0
132
Member Avatar for dirbax

It might look harder than it is. Here's an explanation of the first one: [code] Input: n Start r at 0. Loop n times (using index from 0 to n-1): * when index is less than n/2: add 1 to r (this is done n/2 times) * when index is …

Member Avatar for Rashakil Fol
0
122
Member Avatar for cppnewb

You probably shouldn't be "going to main". Remove the [icode]return main();[/icode] part and change it to a loop.

Member Avatar for nucleon
0
130
Member Avatar for NRaf

Narue, can you really dynamically allocate a [b]static[/b] array in C99? Just seems odd. Is it only sized on the first call in your example?

Member Avatar for Narue
0
107
Member Avatar for robotnixon

Here's a function that uses a set to remove duplicates from a vector without changing the order of elements: [code] void remove_dups (vector<string>& v) { set<string> s; pair<set<string>::iterator, bool> result; for (vector<string>::iterator i = v.begin(); i < v.end(); ++i) { result = s.insert(*i); if (!result.second) { v.erase(i); --i; // adjust …

Member Avatar for robotnixon
0
553
Member Avatar for BruenorBH

You're mixing C-strings and the C++ [b]string[/b] class. Here you just want plaing old C-strings, which do not have member functions associated with them, so you can't do the substr thing. Just do it in a normal old C way.

Member Avatar for BruenorBH
0
114

The End.