Search Results

Showing results 1 to 40 of 168
Search took 0.06 seconds.
Search: Posts Made By: Salem ; Forum: C and child forums
Forum: C Sep 17th, 2009
Replies: 20
Views: 820
Posted By Salem
Post your code!
Did you initialise i ?
Forum: C Sep 15th, 2009
Replies: 16
Views: 682
Posted By Salem
> temp=(char**)malloc(rows);
The red is a cast expression, and is unnecessary.

And it is also HORRIFICALLY wrong on the size as well - damn, didn't spot that one earlier.

It should be
temp=...
Forum: C Sep 13th, 2009
Replies: 3
Views: 288
Posted By Salem
So use a counter.
Forum: C Sep 12th, 2009
Replies: 1
Views: 406
Posted By Salem
Forum: C Sep 10th, 2009
Replies: 8
Views: 416
Posted By Salem
http://www.daniweb.com/forums/post982800.html#post982800

What you're trying smells like this (http://www.urbandictionary.com/define.php?term=turd%20polishing)

Seriously, the only answer you'll...
Forum: C Sep 10th, 2009
Replies: 8
Views: 416
Posted By Salem
> Let's say I am using Turbo C compiler in Windows
Sure, why not - if you consider amputation to be a suitable first step to running a marathon.

I shouldn't worry about memory leaks in TurboC. ...
Forum: C Sep 10th, 2009
Replies: 2
Code Snippet: file_read block
Views: 867
Posted By Salem
> file_content = (char *) realloc (file_content, sizeof(char) * file_size);
Is this C or C++?
If it is C, then you don't need the cast.

However, what happens if realloc fails? The problem is,...
Forum: C Sep 7th, 2009
Replies: 9
Views: 414
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 6th, 2009
Replies: 9
Views: 332
Posted By Salem
Well you need to read how printf() and scanf() work.

scanf ("%f", METERS);

should be
scanf ("%f", &METERS);


Now go find out how to print parameters using printf as well (%d and all that...
Forum: C Aug 29th, 2009
Replies: 1
Views: 245
Posted By Salem
> when i am runing the server program and doing telnet 127.0.0.1 int the console
What command did you actually type?
telnet without additional parameters will try to connect to port 23
Your server...
Forum: C Aug 26th, 2009
Replies: 17
Views: 643
Posted By Salem
I've no idea.
I stripped the code down to something simple, and it seems clean here.

/*-------------------------------------------------------------------------
* SphereInterface.c - Library...
Forum: C Aug 26th, 2009
Replies: 17
Views: 643
Posted By Salem
> I'm running on fedora 10
Excellent.

Then you can try either of these and see what's going on.

valgrind ./myprog

valgrind (http://valgrind.org/) is a tool used for spotting all sorts of...
Forum: C Aug 25th, 2009
Replies: 17
Views: 643
Posted By Salem
Regarding casting malloc.
Here's why it's a really BAD idea.
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1047673478&id=1043284351

Second, are these the ONLY malloc calls in your...
Forum: C Aug 13th, 2009
Replies: 6
Solved: Unusual c code
Views: 350
Posted By Salem
Yes, it's OLD C, and it defaults to int.
Forum: C Aug 11th, 2009
Replies: 5
Views: 323
Posted By Salem
> int a; //which is a definition
Actually, this is just a tentative definition (http://dirac.uos.ac.kr/lang/ccc/Language_Reference/DOCU_004.HTM#tentative_definitions_sec)
At the point of compiling...
Forum: C Aug 10th, 2009
Replies: 5
Views: 421
Posted By Salem
This is a catalogue of some experiments on just two aspects of undefined behaviour.

This was inspired by yet another long bout of explanation in a recent thread, so I thought it was time to dust...
Forum: C Aug 10th, 2009
Replies: 5
Views: 568
Posted By Salem
If you're creating a win32 console game, try
http://www.adrianxw.dk/SoftwareSite/Consoles/Consoles5.html
Forum: C Aug 6th, 2009
Replies: 13
Views: 618
Posted By Salem
> If f() is called first than, the whole purpose of precedency is lost.
Oh man, learn to read.

f() called first, result stored in temp1 - have we done + or * yet - no.
g() called next, result...
Forum: C Aug 5th, 2009
Replies: 10
Views: 719
Posted By Salem
> main() or void main() or int main() it worked for me
Understand that there is a difference between the language and a compiler.

The language states that main returns int.

Your compiler (just...
Forum: C Aug 2nd, 2009
Replies: 2
Views: 203
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 Aug 1st, 2009
Replies: 5
Views: 379
Posted By Salem
> i is an independent value and i think it's value should increase infinitely
It has to exist in memory SOMEWHERE.

The most likely scenarios are

+=========+
| i |
+=========+
|...
Forum: C Jul 29th, 2009
Replies: 11
Views: 574
Posted By Salem
Start with something simple, like python.

You'll actually get some useful things done in a fairly short time frame.

It'll take 6 months of hard graft before you're in any shape to write a...
Forum: C Jul 27th, 2009
Replies: 13
Views: 679
Posted By Salem
> Tell me how this advice will help the op solves his(her) problem, I'm curious...
The OP is basically looking for the front end of a C compiler.
This is far from being a trivial problem.

lex /...
Forum: C Jul 26th, 2009
Replies: 3
Views: 225
Posted By Salem
SELECT * FROM users WHERE postcount = 1 AND effort = 0% (http://www.daniweb.com/forums/post929872-2.html)
Error - too many rows
Forum: C Jul 21st, 2009
Replies: 11
Views: 673
Posted By Salem
So who did you copy that code from?
That style of C has been obsolete for 20+ years.
Forum: C Jul 20th, 2009
Replies: 7
Views: 487
Posted By Salem
@yellowSnow
And if fgets() returns NULL because of an error (and not because of end of file), then what?
Forum: C Jul 20th, 2009
Replies: 7
Views: 487
Posted By Salem
Don't use feof() to control a loop (http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046476070&id=1043284351)

Use
while ( fgets(buffer,sizeof(buffer),myfile) != NULL )
Forum: C Jul 14th, 2009
Replies: 30
Views: 1,626
Posted By Salem
Well to be pedantic again, you should have written
const char *p="abc";
then the compiler itself would have complained about the attempt to modify a constant.

Because so much existing code...
Forum: C Jul 14th, 2009
Replies: 30
Views: 1,626
Posted By Salem
> NOte that here break 1 (p++) and break2 (*p++ ) doing the same thing.
Better add someone else to the reading list....

No they're not the same, one merely increments the pointer, the other one...
Forum: C Jul 13th, 2009
Replies: 30
Views: 1,626
Posted By Salem
It seems that most people other than Tom Gunn need to swing by here and have a nice long read.

http://c-faq.com/aryptr/index.html
Forum: C Jul 13th, 2009
Replies: 30
Views: 1,626
Posted By Salem
> char *p = &q;
Did you try it?

&q has a different type to q, so any good compiler would complain about incompatible pointer assignments.
Forum: C Jul 12th, 2009
Replies: 30
Views: 1,626
Posted By Salem
The first ++ tried to modify what p points to.
Since p points to a string constant, your program dies because it tried to modify something in read-only memory.
Forum: C Jul 9th, 2009
Replies: 4
Solved: strdup-casting
Views: 288
Posted By Salem
Only that strdup() isn't a portable function.
Forum: C Jul 1st, 2009
Replies: 21
Views: 1,190
Posted By Salem
I see the OP got their wish by successive approximation without having to put in any more effort.

Congrats to all :icon_rolleyes:
Forum: C Jun 26th, 2009
Replies: 16
Views: 686
Posted By Salem
> void main()
Mentioned before, so I'll mention it again.
main returns an int, not void

> total=total+a;
Is the initial value of total zero?
Forum: C Jun 24th, 2009
Replies: 10
Solved: Data Type
Views: 616
Posted By Salem
Run from one forum to another asking the same question over and over until you get an answer on a plate (http://cboard.cprogramming.com/c-programming/117100-factorial-100-a.html)
Forum: C Jun 19th, 2009
Replies: 21
Views: 1,112
Posted By Salem
> Bad part is we have to use Miracle C to compile and build
http://www.daniweb.com/forums/thread193907.html
Like I said before, you need to slap your tutor about the head with an educational 2x4...
Forum: C Jun 15th, 2009
Replies: 2
Views: 941
Posted By Salem
> plz tell me how to convert a c code to matlab code
Why would you want to?

When you can already do this...
http://en.wikipedia.org/wiki/MATLAB#Interactions_with_other_languages
Forum: C Jun 9th, 2009
Replies: 9
Views: 558
Posted By Salem
> fact = fact(number);
How does the compiler decide what you mean?
Forum: C Jun 7th, 2009
Replies: 11
Views: 656
Posted By Salem
> will it crash the program?
Whether it does or not doesn't matter.

Code which tries to do such things is broken. The lack of a crash doesn't make it any less broken (only harder to diagnose and...
Showing results 1 to 40 of 168

 


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

©2003 - 2009 DaniWeb® LLC