Search Results

Showing results 1 to 40 of 63
Search took 0.08 seconds.
Search: Posts Made By: Sci@phy ; Forum: C and child forums
Forum: C Nov 13th, 2008
Replies: 13
Views: 867
Posted By Sci@phy
Please post entire code, because your code should work then.
Forum: C Nov 13th, 2008
Replies: 13
Views: 867
Posted By Sci@phy
You have to do it for EACH i.
So put it in for loop
Forum: C Nov 13th, 2008
Replies: 13
Views: 867
Posted By Sci@phy
Oh, yes... Your temp is actually same memory space as ptr. So:

temp[0] = ptr[99]
...
temp[99]=ptr[0]

But ptr[0] is temp[0], which is actually ptr[99]

You have to make a REAL copy of ptr to...
Forum: C Nov 13th, 2008
Replies: 13
Views: 867
Posted By Sci@phy
I apologise, my bad (still early in the morning here :) )
I just realised that you decrease ptr_size2, not ptr_size, so it shouldn't be problem there.
Forum: C Nov 13th, 2008
Replies: 13
Views: 867
Posted By Sci@phy
I only gave you an idea... Probably I messed up some interators, so in some point you call temp[negative]...
Check for this, it shouldn't be hard
Forum: C Nov 13th, 2008
Replies: 13
Views: 867
Posted By Sci@phy
Problem is you are going both ways!
You are incrementing i iterator and at same time decrementing ptr_size2.
Write something like:

ptr_size2 = ptr_size;
temp = ptr;
while (ptr_size2>=0) {...
Forum: C Nov 12th, 2008
Replies: 5
Views: 547
Posted By Sci@phy
It works on my Dev-cpp (mingw, gcc) compiler, and I can't see any problem with code, so it's probably something about your compiler.
Forum: C Nov 3rd, 2008
Replies: 10
Views: 806
Posted By Sci@phy
You can drive your car without fastening seat belt, or walk through minefield :)
But it's risky!

So always use int main() and return zero if succesful (in which case you don't even need to write...
Forum: C Nov 2nd, 2008
Replies: 4
Solved: Sine Series
Views: 1,408
Posted By Sci@phy
And a little piece of advice. When working with decimal numbers, don't use float, instead use more precise double.
Forum: C Oct 26th, 2008
Replies: 10
Solved: Trie's in C
Views: 2,578
Posted By Sci@phy
Do you know why do you use typedef?
It's syntax should be:

typedef some huge type A_DEF;


And the code you wrote has no use from typedef since you haven't specified name that will replace...
Forum: C Oct 26th, 2008
Replies: 10
Solved: Trie's in C
Views: 2,578
Posted By Sci@phy
Funny:

typedef struct node {
char value;
bool isroot;
bool isend;
struct node* sibling;
struct node* child;
}; //<== if semicolon goes here, it's much more reasonable
Forum: C Oct 25th, 2008
Replies: 2
Views: 516
Posted By Sci@phy
Forum: C Oct 23rd, 2008
Replies: 3
Views: 525
Posted By Sci@phy
Why not simplify things?
num=rand()%(max+1);
Forum: C Oct 20th, 2008
Replies: 6
Solved: Help Please
Views: 533
Posted By Sci@phy
Although, if you're doing it for class of some sort, wouldn't it be better to make your own toupper? Just a thought.
Remember, letters are stored actually as ascii code, and you can "add" them or...
Forum: C Oct 20th, 2008
Replies: 6
Views: 536
Posted By Sci@phy
A lot of things!
First, recheck your syntax, there are many errors.
And you cannot declare void function and then expect to get some result from it!
Forum: C Oct 19th, 2008
Replies: 4
Views: 620
Posted By Sci@phy
Will turbo C++ allow C99 standard things? If it compiles C code, not C++.
(I don't know if a turbo c++ compiler can compile C like plain C or it compiles it as C++?)
Forum: C Oct 19th, 2008
Replies: 24
Views: 8,799
Posted By Sci@phy
Ahh, I knew someone will say something like that :)
Of course it can be dangerous, so are pointers (but we still use those).



For first this I have only one answer: scanf("%40s", string);
For...
Forum: C Oct 19th, 2008
Replies: 1
Views: 304
Posted By Sci@phy
I think that for binary search you need sorted list... so if you have unsorted array, linear search will have to do.
Otherwise, binary is faster
Forum: C Oct 19th, 2008
Replies: 24
Views: 8,799
Posted By Sci@phy
And yet, scanf can be clever function:

#include <stdio.h>

int main(){
char dump, string[40];

printf("Enter whole sentece (yeah, bring spaces too, I can handle it):\n");
scanf...
Forum: C Oct 18th, 2008
Replies: 4
Views: 620
Posted By Sci@phy
First you write code in some text editor. It doesn't matter what editor, it could even be notepad.
Then you have to compile that code.
Compilation refers to the processing of source code files (.c,...
Forum: C Oct 18th, 2008
Replies: 9
Views: 600
Posted By Sci@phy
From my head :P

Seriously, reallocating for every integer may not be SO time consuming because on most of the time, realloc could just append to existing memory space. But it still IS time...
Forum: C Oct 18th, 2008
Replies: 9
Views: 600
Posted By Sci@phy
Well, if you're not going to acces members randomly but from begining to the end, maybe list would be perfect?

On the other hand, you could use realloc for every n members (you choose n, but I...
Forum: C Oct 18th, 2008
Replies: 16
Views: 2,598
Posted By Sci@phy
It should be like this (yeah, I like writing nonesence):

int i = 0;
while ((string[i++] = getchar())!='\n');
string[i]='\0';
Forum: C Oct 17th, 2008
Replies: 6
Views: 801
Posted By Sci@phy
The only reason this code should give you error is if you input something else that float, let's say letter. So please post what number did you entered for its first input?

And please, write:
int...
Forum: C Oct 17th, 2008
Replies: 2
Views: 1,548
Posted By Sci@phy
And that's why I always say: start with C first.
If you're making linked list, you don't use [].

Inside your main() you just hold head pointer which points at first node.

Your create_node code...
Forum: C Oct 17th, 2008
Replies: 7
Views: 700
Posted By Sci@phy
I (and presumably lots of people) don't understand your question at all.
Maybe providing us with some example of what you want to do or something
Forum: C Oct 17th, 2008
Replies: 11
Views: 1,895
Posted By Sci@phy
In C standard fflush accepts only output buffers, not input.
Although most compilers do clear std buffer if you write fflush(stdin) it's not a good idea to do that, because generaly, there is no...
Forum: C Oct 16th, 2008
Replies: 9
Views: 1,569
Posted By Sci@phy
Use strcpy(string_to_be_copied, string_with_values_to_be_copied) to copy one string to another.
Forum: C Oct 16th, 2008
Replies: 4
Views: 2,002
Posted By Sci@phy
You could write your hex-to-deci function, and then you can simply write
char a = hex-to-deci-function(hex_num)
Forum: C Oct 15th, 2008
Replies: 7
Views: 1,599
Posted By Sci@phy
It says
If that was your question?

Furthermore, read this, I think it should help you: realloc() info (http://www.cplusplus.com/reference/clibrary/cstdlib/realloc.html)

Bottom point is, you...
Forum: C Oct 14th, 2008
Replies: 10
Solved: printf
Views: 874
Posted By Sci@phy
Thank you for your answers :)
Forum: C Oct 14th, 2008
Replies: 5
Views: 597
Posted By Sci@phy
Why do you think it is C++? :|
Forum: C Oct 14th, 2008
Replies: 7
Poll: program in c
Views: 690
Posted By Sci@phy
The first one is "passing arguments to pointers". In that way, you can change original variable!
Second one is "passing arguments as references".
You cannot do that in C, C always passes arguments...
Forum: C Oct 14th, 2008
Replies: 10
Solved: printf
Views: 874
Posted By Sci@phy
@Narue
I see you are using goto.

And I know programmers don't like to use goto, so if I may ask: why? :)
Did you just use it because it's fastest to write code like that?
Or would you still use...
Forum: C Oct 12th, 2008
Replies: 10
Views: 840
Posted By Sci@phy
It goes like this:
n(0) = 1;
n(1) = 1;
n(2) = n(1), n(2) //so it's actually two numbers
n(3) = n(1), n(2), n(3)...

Bottom line is: First two numbers just copy.
The print others in a for loop
Forum: C Oct 12th, 2008
Replies: 6
Views: 737
Posted By Sci@phy
Flushes everything (like a damn good toilet :) )
Forum: C Oct 12th, 2008
Replies: 7
Solved: Weird error
Views: 489
Posted By Sci@phy
Just some literature from wikipedia:
"In C99, there is a bool type, along with the values true and false, defined in the <stdbool.h>"
Forum: C Oct 12th, 2008
Replies: 3
Views: 1,829
Posted By Sci@phy
1. You are making memory leaks all over the place. When you operate with dynamic memory allocation you have the responsibility to free every part of memory that you don't use.

2. Instead of void...
Forum: C Oct 12th, 2008
Replies: 15
Views: 1,081
Posted By Sci@phy
On line 22 you are declaring function. There's no semicolon in the end.
Main is also a function. Do you write: int main();
Forum: C Oct 11th, 2008
Replies: 4
Solved: scanf problem
Views: 593
Posted By Sci@phy
I doubt that IT printed out properly. Maybe you retyped it, because on my compiler (gcc) problem is with blank space after last %d that exists in his code, and so scanf asks for continuation of...
Showing results 1 to 40 of 63

 


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

©2003 - 2009 DaniWeb® LLC