Search Results

Showing results 1 to 40 of 113
Search took 0.03 seconds.
Search: Posts Made By: Clockowl ; Forum: C and child forums
Forum: C Apr 14th, 2009
Replies: 19
Solved: array help
Views: 685
Posted By Clockowl
Give it a shot here: http://www.cplusplus.com/doc/tutorial/

When you're stuck on a tutorial, you can ask for help of course.
Forum: C Dec 26th, 2008
Replies: 7
Views: 543
Posted By Clockowl
That void* to char* isn't even giving me a warning with -Wall in GCC so I suspect that it's not necessary at all. This isn't C++.

Don't forget that void means (afaik) "lack of type", so you can...
Forum: C Dec 26th, 2008
Replies: 7
Views: 543
Posted By Clockowl
Ah yes, weird.. Weird.

I disagree with this:

"The string is a constant, so calling strlen() every time is only going to waste time, because it always returns the same result."

I'm expecting...
Forum: C Dec 26th, 2008
Replies: 7
Views: 543
Posted By Clockowl
Hey guys,

This program gives me a nice segfault (on line 27 and if it's removed on the realloc() below that) and I can't seem to figure out why. Any help is greatly appreciated.


#include...
Forum: C Nov 23rd, 2008
Replies: 5
Views: 1,938
Posted By Clockowl
Nah I just meant to say that if you're sure that you'll only use it on your system, why not use those compiler specific functions? I think it's overkill to make basically everything you create cross...
Forum: C Nov 23rd, 2008
Replies: 5
Views: 1,938
Posted By Clockowl
I'm more of a newb but feeling cocky as always:

Don't AVOID compiler specific functions, but be sure to find a cross-compiler way to do it as well, as in: find it, use it a couple of time,...
Forum: C Nov 18th, 2008
Replies: 12
Views: 1,833
Posted By Clockowl
Not in any imaginable way if you ask me. Like I said, a pointer to an array of pointers (an array of "arrays") resembles a 2D array. Unless you want that, there's no use for a double pointer.

You...
Forum: C Nov 17th, 2008
Replies: 12
Views: 1,833
Posted By Clockowl
It is only a pointer, don't worry. It's a pointer that points to pointers.

The struct declaration indeed only reserves one pointer, not an array or anything.

However, I guess you want to have...
Forum: C Nov 17th, 2008
Replies: 12
Views: 1,833
Posted By Clockowl
hehe, you should access sc.students then, not students. ;)
Forum: C Nov 17th, 2008
Replies: 12
Views: 1,833
Posted By Clockowl
#
students = malloc(sizeof(struct student));
#
strcpy(students[0]->name, "jack");

I might have missed it, but of what type is "students"? It seems to be an int, since the declaration is lacking...
Forum: C Nov 17th, 2008
Replies: 7
Views: 710
Posted By Clockowl
Well for one change your extension from .cpp to .c, since there's no other way for the compiler to know if it's compiling C or C++ code (except maybe a parameter).
Forum: C Oct 17th, 2008
Replies: 11
Views: 1,852
Posted By Clockowl
Only plain wrong if you're not using a compiler that has defined it. Given that that's not the case most of the time: check your compiler's documentation and see if you can use it, then, bare in mind...
Forum: C Oct 16th, 2008
Replies: 9
Views: 1,424
Posted By Clockowl
But don't do that on those strings. Just accept that they are read-only, you are *not* allowed to write to them, end of story.
Forum: C Oct 16th, 2008
Replies: 9
Views: 1,424
Posted By Clockowl
iostream isn't a C library? afaik it's stdio.h.

C++ has different rules regarding this issue apparently.
Forum: C Oct 16th, 2008
Replies: 4
Views: 1,382
Posted By Clockowl
What OS and compiler are you using?
Forum: C Oct 16th, 2008
Replies: 9
Views: 1,424
Posted By Clockowl
You wouldn't want to do that, I think it's undefined behaviour when you try to do that. Why can't you create your array of char arrays like Aia said?

char d[][5]
Forum: C Oct 15th, 2008
Replies: 7
Views: 1,475
Posted By Clockowl
>Oh, and there's absolutely no guarantee that the memory will (or won't) move on every single call, whether you're making it bigger, smaller or the same size.
-
I don't know when it "doesn't work",...
Forum: C Oct 15th, 2008
Replies: 7
Views: 1,475
Posted By Clockowl
In no implementation it copies if the size is bigger?

My doubt is that it DOES copy when the size is smaller, so it seemed logical it also does that when the size increases, but the it's...
Forum: C Oct 15th, 2008
Replies: 7
Views: 1,475
Posted By Clockowl
Hey guys,

I was wondering if realloc() copied the contents of the block of memory to the new block "on most compilers" IF the new size is bigger. I like to learn good ways to program something,...
Forum: C Oct 13th, 2008
Replies: 2
Solved: Regression
Views: 382
Posted By Clockowl
Regression? Don't you mean iteration? Could be wrong, but according to wiki (I had to look it up) regression is bug-related, not loop related like recursion.

If you mean iteration, then that is...
Forum: C Oct 12th, 2008
Replies: 4
Solved: c vs assembly
Views: 911
Posted By Clockowl
Define "doing the same thing".

I can drive to the store on my bike and in my car, doing 2 different things. Or I can say that I'm going to the store, doing one thing, in 2 ways.

C compilers...
Forum: C Oct 6th, 2008
Replies: 3
Views: 3,628
Posted By Clockowl
Here you go:

http://www.xmission.com/~nate/glut.html

If you're on windows that is. Else, you need to download glut.h from somewhere else for Linux.. don't know much about linux, sorry.
Forum: C Oct 1st, 2008
Replies: 5
Views: 515
Posted By Clockowl
You'd better go and code something yourself I think, or show us what you have so far. Of course, that needs to be more than the code posted above + some misc. main function.
Forum: C Oct 1st, 2008
Replies: 9
Views: 1,685
Posted By Clockowl
Narue: It's somewhere on this board, let me look it up. Edit: found it:
http://www.daniweb.com/forums/thread137672.html

Code: int fileSize = 0;
int n, i, j;
printf("Opening file:...
Forum: C Oct 1st, 2008
Replies: 2
Views: 384
Posted By Clockowl
Thanks, nice site by the way.
Forum: C Oct 1st, 2008
Replies: 9
Views: 1,685
Posted By Clockowl
Hmz.. I remember using fread() on a none-binary file, passing the fileSize (in the count and size parameters of course) and it read almost everything okay, but it messed up the last few lines: the...
Forum: C Oct 1st, 2008
Replies: 2
Views: 384
Posted By Clockowl
How would I reuse functions in C? I've tried simply sticking them in a #include <myfunctions.h>, but that didn't work... Any (complete) suggestions/links on how to do this? I googled some and found...
Forum: C Oct 1st, 2008
Replies: 9
Views: 1,685
Posted By Clockowl
How would one use fread() then with a text file, considering you can't determine the size fread will read?
Forum: C Oct 1st, 2008
Replies: 9
Views: 1,685
Posted By Clockowl
Is it possible to read a whole file at once with text files, or can I only use fgets and is that the most data I can fetch at any time? (fread() doesn't work on text files, I've experienced and then...
Forum: C Sep 16th, 2008
Replies: 3
Views: 1,071
Posted By Clockowl
You'll need 64-bits integers for that. Depends on your compiler (afaik) if it supports it. Look it up. If your compiler supports a bit of C99, you should be able to do:


unsigned long long int b...
Forum: C Sep 16th, 2008
Replies: 2
Views: 521
Posted By Clockowl
Howdy folks,

Does anyone know if GCC is capable of creating a fixed length 1D array of an N-Dimensional array for reasons of speed? I've heard it matters quite a lot if one works constantly with...
Forum: C Aug 27th, 2008
Replies: 5
Views: 943
Posted By Clockowl
You can use atoi() for converting "ASCII" to "integer". :)
Forum: C Aug 16th, 2008
Replies: 2
Views: 382
Posted By Clockowl
It's the only way eh? Well I unrolled the loop as it's only 4 iterations, but thanks a lot for your input. :)
Forum: C Aug 16th, 2008
Replies: 2
Views: 382
Posted By Clockowl
Hi guys,

I've got two loops, and I want to be able to continue; the outermost loop when the innermost loop finds something. How would I do that?


//(...)
for (n = startStorage; n <...
Forum: C Aug 15th, 2008
Replies: 14
Views: 1,257
Posted By Clockowl
Lessons in pretty advanced C for me. Never seen it used before.
Forum: C Aug 15th, 2008
Replies: 14
Views: 1,257
Posted By Clockowl
Thanks for pointing that out Aia.

Still I'd like to suggest changing it to the above code for readability. It seems like you don't need to make it a pointer. If you still like it to be a pointer,...
Forum: C Aug 15th, 2008
Replies: 14
Views: 1,257
Posted By Clockowl
Erm.. I think you are creating an array of 40 char pointers... Not sure tho.

char (*str)[40] =(*env)->GetStringUTFChars(env,s,0);


Try this:

char str[40];

Same seem to be errors in...
Forum: C Aug 15th, 2008
Replies: 14
Views: 1,257
Posted By Clockowl
I must admit I don't know 100% what you're trying to do, but as far as I know, a C-style string object _is_ a general character array. Maybe you can create a function that returns a <char *> and...
Forum: C Aug 12th, 2008
Replies: 6
Views: 804
Posted By Clockowl
By the way blrjohn, you could also try and fire up a console and execute your program from there. It won't disappear then. I dunno on which OS you are, but guessing it's Windows (80% market share or...
Forum: C Aug 10th, 2008
Replies: 10
Views: 2,466
Posted By Clockowl
Then you need to parse the string first.. That can be pretty hard.

Try to understand how you do it, how you calculate f(x), write that down in steps on paper or on your computer and post it here.
Showing results 1 to 40 of 113

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC