Forum: C Mar 31st, 2009 |
| Replies: 10 Views: 688 There is an initialization failure ...
for( i = 0; i < n; i++ ) numberlist[i] == rand() % n ; |
Forum: C Mar 3rd, 2009 |
| Replies: 6 Views: 446 Try going through the py2exe tutorial (http://www.py2exe.org/index.cgi/Tutorial).
If you'll use py2exe to assemble all the files your python prog needs, you can skip the idea of coding anykind... |
Forum: C Jul 23rd, 2008 |
| Replies: 8 Views: 1,038 ...
double CelsiusToFahrenheit(double c);
...
int main()
{
...
}
double CelsiusToFahrenheit(double c) ; // <- remove the semicolon
{ |
Forum: C Jul 22nd, 2008 |
| Replies: 38 Views: 2,397 Isn't that quite obvious if you take a close look at the loop,
for(k=1;k<=10;k++)
{
// do this ten times ...
// ask the user for the file name <-> shouldn't you
// open the... |
Forum: C Jul 15th, 2008 |
| Replies: 2 Views: 470 The function is malloc(), not maloc(). |
Forum: C Jun 9th, 2008 |
| Replies: 13 Views: 2,323 The problem probably lies in how you use indexes. Note that array indexes are zero-based i.e. if you have an array holding 5 elements, the last valid index is 4, not 5. Consider
const char... |
Forum: C Jun 8th, 2008 |
| Replies: 11 Views: 1,367 You might post the relevant parts of the code, otherwise there is no way to help much more. |
Forum: C Jun 8th, 2008 |
| Replies: 11 Views: 1,367 How about getting rid of the original magic altogether? So you'd have untouched argv[] and simply hard-coded opt_httphost = "the hard-coded address";. |
Forum: C Jun 8th, 2008 |
| Replies: 11 Views: 1,367 The memory that argv[0] points to is not writable.
Why don't you just do something like
opt_httphost = "the hard-coded address"; |
Forum: C May 13th, 2008 |
| Replies: 5 Views: 668 << if I try to push changed data using function, I get just the same word n times:
That happens because you are pushing pointers to one single buffer you have in your whole program, and that buffer... |
Forum: C May 6th, 2008 |
| Replies: 12 Views: 1,192 Anyone interested in programs written in similar fashion can take look at here
http://www2.de.ioccc.org/years.html#2004 |
Forum: C Apr 27th, 2008 |
| Replies: 5 Views: 742 You could turn Ancient Dragon's code into a function and then use it to process your input file line-by-line. It could look something like (the function is here AD())
void AD(char * record, char *... |
Forum: C Apr 12th, 2008 |
| Replies: 3 Views: 5,561 You cannot do it like that, 'word' is there a pointer to a char.
So, try with an array of chars instead
char word[21] = "";
scanf("%20s",word); // at max, 20 characters get scanned to the 'word' |
Forum: C Apr 11th, 2008 |
| Replies: 4 Views: 495 No, you need to get a working understanding of the keyword 'extern' in C/C++. |
Forum: C Apr 11th, 2008 |
| Replies: 4 Views: 495 The problem is that there probably is no definition of the variable muscleTendonLength anywhere (hence the linker really is unable to do its job).
See
http://c-faq.com/decl/decldef.html
and place... |
Forum: C Apr 9th, 2008 |
| Replies: 3 Views: 1,466 Are you 100% sure that e.g. "Inside Signal Handler" doesn't get printed the second time at that time?
That is because Windows has restored the handler i.e. your handler is not in effect anymore... |
Forum: C Mar 21st, 2008 |
| Replies: 6 Views: 742 You are trying to use a string "\0" there, instead you have to use '\0', i.e.
if (x==strlen(a))
current[x+1] = '\0';
and be careful not to access indexes that are out of bounds. |
Forum: C Mar 21st, 2008 |
| Replies: 6 Views: 742 You might also make use of the strstr() function
http://www.cplusplus.com/reference/clibrary/cstring/strstr.html |
Forum: C Mar 18th, 2008 |
| Replies: 11 Views: 4,083 Try valgrind
http://valgrind.org/info/
As a general note, you should add error checking to your code. As of now, there is none. |
Forum: C Mar 12th, 2008 |
| Replies: 12 Views: 1,920 Anyone interested in various ways of calculating factorials should look into
http://www.luschny.de/math/factorial/FastFactorialFunctions.htm |
Forum: C Mar 12th, 2008 |
| Replies: 12 Views: 1,920 You should also handle factorial of zero i.e. 0! |
Forum: C Mar 8th, 2008 |
| Replies: 6 Views: 1,372 Good questions ... I'd suggest you to take some time and see e.g.
http://publications.gbdirect.co.uk/c_book/chapter5/pointers.html |
Forum: C Mar 8th, 2008 |
| Replies: 6 Views: 1,372 The following can also be done .. it does not involve strcpy() or arrays,
instead it uses a single pointer (real_out_ptr)
char const * real_out_ptr = "This REALLY shouldn't have happened.\n";
... |
Forum: C Mar 7th, 2008 |
| Replies: 4 Views: 528 p.level is an integer, hence %d instead of %s ...
int viewcharacter()
{
printf("Name:\t%s\n", p.name);
printf("Level:\t%d\n",p.level);
} |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 You are having a following kind of construct, where the compiler does not know what Sort actually is inside the main() function.
#include <stdlib.h>
// Declaration of Sort commented out
// int... |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 Change:
qsort((void*)word, wcount, sizeof(WORD), int(*Sort)(const void*, const void*));
to
qsort((void*)word, wcount, sizeof(WORD), Sort); |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 Umm .. that should be easy to solve, I take that you have also declared the Parse() function, so the Sort() function should be declared in same fashion. |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 int Sort(const void *l, const void *r)
{
WORD *left = (WORD *) l;
WORD *right = (WORD *) r;
int n;
if(left->count == right->count){
n =... |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 Because pl and pr both are pointers to void, you cannot use them as such to access the data they point to. Hence you need to type cast them properly before usage.
The only correct choice here is to... |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 If you have:
WORD * pLeft = (WORD *) pl;
then you use pLeft->count and pLeft->word
and the same way
pRight->count and pRight->word
So you can e.g. compare the words by calling:... |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 I'd rather use something like
if(MAXWORDS == wcount)
{
printf("Error: maximum number of words (%d) already used. Aborting ...\n", MAXWORDS);
exit(1);
}
In general, whenever your... |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 Just remembered that I did not answer your question:
"Regarding the checking if the wcount is still less than the MAXWORDS, what output should I make if ever the wcount is still right or vice... |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 First of all, your sort function (you need only one of them actually), has to be declared as
int mySort(const void * pl, const void * pr)
otherwise it will not compile/work.
The qsort() calls... |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 << in what order this qsort sorts a certain list?
You don't actually have to think about it, leave it as an internal of qsort().
Just be sure that your own sort function works as planned and... |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 Well it is getting closer ... but there are errors, I try to explain.
void Insert(char *token)
{
int i, loop;
// Array indexes are zero-based, hence you start from 0,
... |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 Sorry to say, but no. The loop should be like;
void Insert(char *token)
{
for(i = 0; i < Count_Of_Words_Inserted_To_Table; i++)
{
// This comparison is OK
n = CompareStr(token,... |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 Oh mine, you still have a local variable WORD word inside the function ... that just won't work.
void Insert(char *token, int loop)
{
int i, n;
WORD word;
}
You must have an array... |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 buffer++ increments the pointer (i.e. buffer) to point to the next character.
The condition "while(*buffer)" could be written as
while('\0' != *buffer)
i.e. loop until you encounter the... |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 Yes, there are two todo:s in the above Insert() function, which you have to do.
The check for exceeding the maximum number of words used in that function is also essential. |
Forum: C Mar 2nd, 2008 |
| Replies: 48 Views: 3,296 void Insert(char *token, int loop)
{
// This won't work at all <=> a single, non-static
// local WORD structure !!!
WORD word;
word[loop].word = token;
... |