Search Results

Showing results 1 to 40 of 304
Search took 0.08 seconds.
Search: Posts Made By: Salem ; Forum: C and child forums
Forum: C Sep 18th, 2009
Replies: 2
Views: 325
Posted By Salem
Standard C doesn't allow you to declare variables in the middle of statement blocks.
Forum: C Sep 17th, 2009
Replies: 20
Views: 807
Posted By Salem
Post your code!
Did you initialise i ?
Forum: C Sep 17th, 2009
Replies: 20
Views: 807
Posted By Salem
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
Posted By Salem
> basechars[r]
You're printing them, not storing them!
Forum: C Sep 17th, 2009
Replies: 20
Views: 807
Posted By Salem
Store each char in another array, then print it out backwards?
Forum: C Sep 17th, 2009
Replies: 20
Views: 807
Posted By Salem
Well it's good for bases < 10

char basechars[] = "0123456789";

and
printf("%c", basechars[r] );
Forum: C Sep 17th, 2009
Replies: 20
Views: 807
Posted By Salem
> 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
Posted By Salem
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
Posted By Salem
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
Posted By Salem
Use %s to print a string of chars.
Forum: C Sep 13th, 2009
Replies: 3
Views: 330
Posted By Salem
> 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
Posted By Salem
You can't assign arrays.
Use strcpy() instead.
Forum: C Sep 10th, 2009
Replies: 3
Views: 435
Posted By Salem
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
Posted By Salem
> 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
Posted By Salem
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
Posted By Salem
> "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
Posted By Salem
> 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
Posted By Salem
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
Posted By Salem
> 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
Posted By Salem
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
Posted By Salem
> 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
Posted By Salem
> 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
Posted By Salem
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
Posted By Salem
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
Posted By Salem
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
Posted By Salem
So what is your question?
Forum: C Aug 21st, 2009
Replies: 1
Views: 246
Posted By Salem
> 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
Posted By Salem
insert() returns a value, which you're ignoring.
Forum: C Aug 13th, 2009
Replies: 6
Solved: Unusual c code
Views: 349
Posted By Salem
Yes, it's OLD C, and it defaults to int.
Forum: C Aug 11th, 2009
Replies: 8
Views: 284
Posted By Salem
Oh yeah!
http://www.daniweb.com/forums/thread210533.html
Forum: C Aug 7th, 2009
Replies: 21
Views: 905
Posted By Salem
http://www.daniweb.com/forums/announcement118-2.html
Forum: C Aug 5th, 2009
Replies: 5
Views: 355
Posted By Salem
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
Posted By Salem
Also consider the lack of usefulness of a string containing only one char (a \0)
Forum: C Aug 2nd, 2009
Replies: 2
Views: 202
Posted By Salem
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
Posted By Salem
There's no such thing as an "array of bits" in C.
Forum: C Jul 28th, 2009
Replies: 12
Solved: SHA-1 in C
Views: 425
Posted By Salem
http://clusty.com/search?query=sha1+source+code&sourceid=Mozilla-search
Forum: C Jul 23rd, 2009
Replies: 10
Views: 335
Posted By Salem
You don't increment the dest array pointer.
The destination isn't big enough.
Forum: C Jul 17th, 2009
Replies: 30
Views: 1,617
Posted By Salem
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
Posted By Salem
You seem to have figured it out - what do you want me to suggest?
Forum: C Jul 15th, 2009
Replies: 12
Views: 627
Posted By Salem
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...
Showing results 1 to 40 of 304

 


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

©2003 - 2009 DaniWeb® LLC