Forum: C Sep 18th, 2009 |
| Replies: 2 Views: 325 Standard C doesn't allow you to declare variables in the middle of statement blocks. |
Forum: C Sep 17th, 2009 |
| Replies: 20 Views: 807 Post your code!
Did you initialise i ? |
Forum: C Sep 17th, 2009 |
| Replies: 20 Views: 807 result[numchars++] = basechars[r];
When you're done, print from numchars-1 back down to 0 (one char at a time). |
Forum: C Sep 17th, 2009 |
| Replies: 20 Views: 807 > basechars[r]
You're printing them, not storing them! |
Forum: C Sep 17th, 2009 |
| Replies: 20 Views: 807 Store each char in another array, then print it out backwards? |
Forum: C Sep 17th, 2009 |
| Replies: 20 Views: 807 Well it's good for bases < 10
char basechars[] = "0123456789";
and
printf("%c", basechars[r] ); |
Forum: C Sep 17th, 2009 |
| Replies: 20 Views: 807 > That is how I get the binary.
That's how you do it for every other base as well. |
Forum: C Sep 14th, 2009 |
| Replies: 5 Views: 694 How would I know.
You've now got two programs, and you've posted the code for neither of them. |
Forum: C Sep 14th, 2009 |
| Replies: 5 Views: 694 if(! CreateProcess("C:\\WINDOWS\\system32\\cmd.exe",
This needs to be something like
if(! CreateProcess("C:\\Users\\me\\Documents\\Projects\\Fib\\myfib.exe",
It does all the work.
This code... |
Forum: C Sep 13th, 2009 |
| Replies: 2 Views: 215 Use %s to print a string of chars. |
Forum: C Sep 13th, 2009 |
| Replies: 3 Views: 330 > if(fgets(temp, sizeof(temp), file) != NULL)
To read the whole file, do
while(fgets(temp, sizeof(temp), file) != NULL)
Oh, and remove the fclose() from inside the loop.
Or better yet, leave... |
Forum: C Sep 11th, 2009 |
| Replies: 2 Views: 227 You can't assign arrays.
Use strcpy() instead. |
Forum: C Sep 10th, 2009 |
| Replies: 3 Views: 435 It would be better if you actually posted your actual error message.
Rather than saying "an error", hoping we can be
a) bothered to run your code
b) actually end up with the same error message... |
Forum: C Sep 10th, 2009 |
| Replies: 16 Views: 681 > Try this..Does it do your job:
Well it might, if you included stdlib.h as well.
Then you might be able to call malloc without having to resort to dangerous casting (it's REALLY dangerous... |
Forum: C Sep 8th, 2009 |
| Replies: 3 Views: 274 To further what Tom Gunn said, if you changed
char name[25]
to
char *name;
then the second printf would immediately be very wrong indeed, and not just ever so slightly odd. |
Forum: C Sep 7th, 2009 |
| Replies: 9 Views: 410 > "program to swap two no. using third variable"
A better question would be:
"How to swap my idiot teacher of 1970's assembler tricks with someone who has a clue about programming in the modern... |
Forum: C Sep 5th, 2009 |
| Replies: 1 Views: 352 > I am trying to work learn thread programming in C.
Mmm-kay,
> I have my turbo C installed and its working fine.
You're stuck then.
> Please do shed some light on how to configure my Turbo C... |
Forum: C Sep 3rd, 2009 |
| Replies: 1 Views: 393 Use fgets() to read each line.
Use sscanf() to parse the line (or better yet, strtod). |
Forum: C Aug 26th, 2009 |
| Replies: 15 Views: 594 > saveToFile(*client_file, *cd);
Neither client_file or cd are initialised.
Something like this
client_file = fopen("data.txt","w");
if ( client_file != NULL ) {
saveToFile(*client_file,... |
Forum: C Aug 25th, 2009 |
| Replies: 15 Views: 594 One function to write the struct to a file.
Another function to read the struct from a file.
For each field, use the appropriate fprintf or fscanf conversion function.
For extra robustness on... |
Forum: C Aug 24th, 2009 |
| Replies: 4 Views: 287 > This is just a skeleton.
In other words, a complete waste of time.
Post an accurate facsimile of your actual problem, and you might get some useful answers.
Post random dribble in a... |
Forum: C Aug 24th, 2009 |
| Replies: 4 Views: 287 > void processone(int delay);
This is an int
> processone(av[1]);
This is a char*
> void processone(char avinput)
This is a char
Making prototype AND definition a char* as well would go a... |
Forum: C Aug 23rd, 2009 |
| Replies: 6 Views: 453 Post some more code, for example all the other declarations of variables used in this code. |
Forum: C Aug 22nd, 2009 |
| Replies: 5 Views: 258 You need to post some context.
What is error 468, (I've no idea, each compiler is different).
Which line is that on?
Does it happen when you compile the program or run it? |
Forum: C Aug 22nd, 2009 |
| Replies: 5 Views: 258 Like so
#include <stdio.h>
#include <string.h>
struct student
{
char studName;
int studID;
char sex; |
Forum: C Aug 22nd, 2009 |
| Replies: 3 Views: 294 So what is your question? |
Forum: C Aug 21st, 2009 |
| Replies: 1 Views: 246 > vararray[v+1]==NULL
Well if vararray is an array of char, then testing the nul character (as opposed to the NULL pointer) is what you should be doing.
As in
vararray[v+1]=='\0' |
Forum: C Aug 20th, 2009 |
| Replies: 2 Views: 182 insert() returns a value, which you're ignoring. |
Forum: C Aug 13th, 2009 |
| Replies: 6 Views: 349 Yes, it's OLD C, and it defaults to int. |
Forum: C Aug 11th, 2009 |
| Replies: 8 Views: 284 Oh yeah!
http://www.daniweb.com/forums/thread210533.html |
Forum: C Aug 7th, 2009 |
| Replies: 21 Views: 905 http://www.daniweb.com/forums/announcement118-2.html |
Forum: C Aug 5th, 2009 |
| Replies: 5 Views: 355 You only enter a string, not a number.
Typing in 123
will likely get you
49 50 51
as output.
If you were expecting 123 to be printed, you need more code.
At the moment, you just print the... |
Forum: C Aug 2nd, 2009 |
| Replies: 5 Views: 374 Also consider the lack of usefulness of a string containing only one char (a \0) |
Forum: C Aug 2nd, 2009 |
| Replies: 2 Views: 202 It's a nice idea.
But there are at least 6 places where code tags are mentioned, and still about 99% of noobs fail to use them on the first post. People get +ve rep just for proving they can read -... |
Forum: C Jul 31st, 2009 |
| Replies: 7 Views: 936 There's no such thing as an "array of bits" in C. |
Forum: C Jul 28th, 2009 |
| Replies: 12 Views: 425 http://clusty.com/search?query=sha1+source+code&sourceid=Mozilla-search |
Forum: C Jul 23rd, 2009 |
| Replies: 10 Views: 335 You don't increment the dest array pointer.
The destination isn't big enough. |
Forum: C Jul 17th, 2009 |
| Replies: 30 Views: 1,617 A short guide to const.
char a;
const char b;
char *p = &a;
const char *q = &b;
char * const r = &a;
const char * const s = &b;
Step 1, read right to left, so for example |
Forum: C Jul 16th, 2009 |
| Replies: 30 Views: 1,617 You seem to have figured it out - what do you want me to suggest? |
Forum: C Jul 15th, 2009 |
| Replies: 12 Views: 627 http://c-faq.com/malloc/index.html
* Memory leak
Calling malloc() without calling free().
* Buffer OverFlow
Accesses outside the bounds of your memory. Can equally apply to arrays as... |