Forum: C Sep 10th, 2007 |
| Replies: 9 Views: 1,639 You can only access an object if it was declared in the same scope or an enclosing scope. That's the techno babble explanation. :) What it means is that if you declare something inside a loop, you... |
Forum: C Sep 7th, 2007 |
| Replies: 9 Views: 1,261 If I'm not comfortable using it, I won't. Simple. You don't need to understand my concern to respect it. :)
The file looks well written, but it'll take me a while to understand it. |
Forum: C Sep 7th, 2007 |
| Replies: 9 Views: 1,261 That's better. Clicking 2 links more that I don't trust _was_ too much trouble. |
Forum: C Sep 7th, 2007 |
| Replies: 9 Views: 1,261 Yeah. rapidshare looks kind of sketchy and I don't want to click any of those links to download your file. :) |
Forum: C Sep 7th, 2007 |
| Replies: 9 Views: 1,261 Maybe nobody wants to download it... |
Forum: C Sep 5th, 2007 |
| Replies: 6 Views: 1,259 Yeah, I know. You should read my post again, and the post above it, more slowly this time. ;) |
Forum: C Sep 5th, 2007 |
| Replies: 6 Views: 1,259 If printf didn't return a value, it would return void. There aren't any values of void type, so something like this shouldn't ever compile. That means it's not valid.
#include <stdio.h>
void... |
Forum: C Sep 4th, 2007 |
| Replies: 7 Views: 1,253 You write a C callable wrapper that runs the method.
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
class Split { |
Forum: C Aug 31st, 2007 |
| Replies: 8 Views: 1,204 I don't know. It looks like CreateRawDataBUFR is corrupting your object, but you didn't post the logic for CreateRawDataBUFR. Without the code I can't even guess where you went wrong. |
Forum: C Aug 31st, 2007 |
| Replies: 3 Views: 3,320 That's not any different from this, except it wastes 999 pointers.
typedef struct
{
long size;
char *data;
}bulk;
bulk blob; |
Forum: C Aug 29th, 2007 |
| Replies: 17 Views: 2,286 system is in stdlib.h, not stdio.h. It's not a good idea either because now you depend on an outside program that might be malicious. It's a big security no-no because you created a hole that hackers... |
Forum: C Aug 29th, 2007 |
| Replies: 17 Views: 2,286 Doesn't printing \n do the same thing as fflush? |
Forum: C Aug 28th, 2007 |
| Replies: 20 Views: 11,552 I thought I'd try to help you improve your appearance. But I guess you don't care. I won't bother you again. |
Forum: C Aug 28th, 2007 |
| Replies: 20 Views: 11,552 It's not a mistake. If I'm not intimately familiar with the details, I can't confirm or deny them. But if your attitude suggests that you don't have an open mind, I can use that to infer that your... |
Forum: C Aug 28th, 2007 |
| Replies: 17 Views: 2,286 The window gets destroyed when the program ends. If you call getchar so that it blocks for input, the program doesn't end and the window isn't destroyed until getchar returns. |
Forum: C Aug 28th, 2007 |
| Replies: 20 Views: 11,552 It's impossible to be totally wrong. :D
I'm not trying to prove you wrong. In the absence of technical arguments, I made that clear before too, your attitude toward alternatives is exactly what... |
Forum: C Aug 28th, 2007 |
| Replies: 20 Views: 11,552 That sounds pretty narrow minded. You found something you like, and other people have to use it too because you won't tolerate listening to other suggestions? Ignoring technical details, that... |
Forum: C Aug 24th, 2007 |
| Replies: 3 Views: 696 This is a really easy program. Have you tried doing it on your own? If so, post what you have and we can work from there. :) |
Forum: C Aug 22nd, 2007 |
| Replies: 16 Views: 1,514 Then why is quicksort so much better than bubblesort? :D It's at least four or five times bigger, but in efficiency there's no comparison. The amount of code doesn't reflect efficiency; the quality... |
Forum: C Aug 22nd, 2007 |
| Replies: 16 Views: 1,514 Since when does size reflect efficiency? :confused: |
Forum: C Aug 22nd, 2007 |
| Replies: 16 Views: 1,514 Just because it's obvious to you doesn't make it obvious to everyone. ;) |
Forum: C Aug 21st, 2007 |
| Replies: 11 Views: 6,115 You get an exception because p2 shouldn't be freed, period. p2 doesn't point to the memory that was returned by malloc; p does. When you want to free, you free p, not p2 or p3, or any other p's that... |
Forum: C Aug 21st, 2007 |
| Replies: 11 Views: 6,115 Then you can't do it efficiently. You _have_ to shift everything in the array to overwrite the 1000 bytes and then realloc the array so that it's 1000 bytes smaller. If you require the 1000 bytes to... |
Forum: C Aug 21st, 2007 |
| Replies: 11 Views: 1,813 Because I didn't know I could do that. ;) That's a good idea, but I'm not worried about the type since it's pretty much not going to change. I was using that sizeof trick to get the number of cells... |
Forum: C Aug 21st, 2007 |
| Replies: 11 Views: 6,115 The fastest way is to shift the pointer. If your array is a pointer made by malloc it's really easy.
p += 1000;
Be sure to shift it back before you free the memory though, or you'll get an... |
Forum: C Aug 21st, 2007 |
| Replies: 11 Views: 1,813 All of the memory for the stack is preallocated. The OS allocates it when the program starts and frees it when the program ends, but while the program is running, it's all still there. Going in and... |
Forum: C Aug 21st, 2007 |
| Replies: 11 Views: 1,813 No, it doesn't. But you _do_ lose the only reference to the space you had, and that's called a memory leak because now it's allocated and won't be freed until the program ends. If your OS doesn't... |
Forum: C Aug 20th, 2007 |
| Replies: 6 Views: 969 Wow, SpS, that's a long tutorial... |
Forum: C Aug 19th, 2007 |
| Replies: 14 Views: 7,258 You could have answered the question you knew was coming before it came and saved me the trouble of asking. ;)
That seems like kind of a pointless requirement... A way to pause the process... |
Forum: C Aug 19th, 2007 |
| Replies: 14 Views: 7,258 Why can't you use a sleep() kind function? |
Forum: C Aug 14th, 2007 |
| Replies: 20 Views: 4,394 Yeah, that's even worse. :D |
Forum: C Aug 14th, 2007 |
| Replies: 20 Views: 4,394 You have to read the course number first, then you can call the function to convert it to upper or lower case.
if ( scanf( " %9s", courseNumber ) != 1 ) {
/* Handle an I/O error */
}
... |
Forum: C Aug 14th, 2007 |
| Replies: 20 Views: 4,394 I think avoiding a second pass over the string is a fantastic reason not to use it. Microseconds add up faster than you might expect. Yeah, both versions work as expected, but my version isn't harder... |
Forum: C Aug 14th, 2007 |
| Replies: 20 Views: 4,394 Pointer strings always end with a '\0' character so calling strlen to find the end just slows the whole function down. This is a good pattern to get in the habit of using.
for ( i = 0; s[i] !=... |
Forum: C Aug 13th, 2007 |
| Replies: 20 Views: 4,394 In the ctype.h (http://en.wikipedia.org/wiki/Ctype.h) header you can find tolower, toupper, islower, and isupper for working with lower and upper case letters. |
Forum: C Aug 13th, 2007 |
| Replies: 3 Views: 697 I know it says so in section 6.3.2.1 but I can't put all of the pieces together enough to answer your question. Sorry. :( |
Forum: C Aug 13th, 2007 |
| Replies: 3 Views: 697 This is a tricky one. The two arrays are incompatible because of the const just like you noticed. The first dimension of an array turns into a pointer so int arr[][3] becomes int (*)[3]. But a... |
Forum: C Aug 13th, 2007 |
| Replies: 8 Views: 1,270 K&R is a book, The C Programming Language. If the tutorial is any good it won't matter what compiler you have, but I recommend visual C++ express because it's free and easy to use once you blank out... |
Forum: C Aug 12th, 2007 |
| Replies: 5 Views: 978 I don't think you can build just an open file. But you can make a dummy project and get the same effect by removing the source files in the project and adding existing items instead of new items to... |
Forum: C Aug 2nd, 2007 |
| Replies: 8 Views: 18,730 You need to include stdlib.h. The error cryptically tells you that malloc wasn't declared and the compiler just assumes it's a function that returns int and casting from int to char* isn't friendly. |