Hi everyone,
I was just wondering, is function overload legal in C as it is in JAVA?
In JAVA, you can have two functions (or methods) with the same name but different argument lists and the...
Type: Posts; User: Cikotic
Hi everyone,
I was just wondering, is function overload legal in C as it is in JAVA?
In JAVA, you can have two functions (or methods) with the same name but different argument lists and the...
OK, now this is it. I can't take this stupidity anymore. I decided to leave the original problem with reverse, hoping that if I read my new book's chapter on pointers, I would understand better. I'm...
This reminds me of an old problem I had. I'd written a programme where I put the contents of the main function in a do...while() loop so that the user can be asked to repeat the process or quit. The...
I don't understand what you mean by "provide a valid prototype to any variadic function. I know printf determines how many arguments it takes based on the first argument.
Secondly, since when is...
So, if I only got the user to input a string, then the value of 'p' wouldn't be read only and could be manipulated by reverse?
About pointers. for my purpose, if I declared p as an array with a...
I always do
gcc -ggdb -Wall prog.c -o prog
ggdb and Wall are just precautions and -o prog is for when you want to keep your executable after your next compile. If you keep the a.out, it'll be...
>>Let me start by asking how long you've been doing C, prelude?
>Coming up on ten years. Wow, kinda scary.
Good: I still have nine and a half years to actually learn C. LOL.
Anyway, so if I have...
Let me start by asking how long you've been doing C, prelude?
Now, I have two problems:
1) what happened to the previous output? Without the \n, should the output have been:
WORD: HELLO
...
Oh, here's the output:
$ ./0ex4-13
Programme to reverse all elements in a string, using recursion.
You will be required to enter a word up to 20 letters long.
WORD: HELLO
Segmentation fault
int main (void)
{
char* s;
char* p = "hello";
printf("Programme to reverse all elements in a string, using recursion.");
printf("\nYou will be required to enter a...
Yes, stdio.h is there.
And I realize that seg faults are good things, I just blame my lack of skills in C on them. Because 1 out of 2 errors I make in C are seg faults because I don't fully...
I HATE SIGSEGV. Why is C programming so much harder than all the other langs? (don't answer that).
Anyway look at the following:
int main (void)
{
char* p = "hello";
...
printf("\n...
Hi everyone,
I've been writing programmes in C for about a year now (with some big gaps in between), and I'm never comfortable with anything I write. It seems that no matter what method I choose to...
Thanx for all your responses. Sorry, I didn't check in earlier.
The programme was supposed to check if all characters in one string are the same, which I think, Salem's programme solved. Today, in...
Hi all,
Recently, in my computer science class, we encountered a problem in a book that seemed impossible to solve. (The teacher couldn't solve it either, so we aren't getting marks for it, which is...
This code is in JAVA. I never wrote the C equivalent, but it should help you understand the math behind finding the square root of a number. This function finds the sqrt with .1 proximity.
...
AAAHHHH. Always the little things that slip my mind!!!
Thanx Salem.
OK, now Cikotic's goin' really psycho.
Take a look at this code from a different programme but with a similar concept:
char* cc = "blah blah blah";
char* op = " -o "; ...
Oh, I just remembered. The second argument of realloc() is the total size that we want for the array not the amount of memory to be added, which means your code is perfect, and I, once again, am in...
Thanx a lot, Hammer, your code makes everything clear now.
But one last thing. You said
... t = realloc(p, ind+2) ...
one space for the new char and one for the terminating NULL character....
WOW. This is a great board, I'm overwhelmed with responses.
Hammer, I thought static makes a var's value the same throughout different calls to the function. what do you mean by a static sized...
Thank you guys for those quick responses.
Salem, what do you mean drop the realloc stuff? What programme would I have without realloc?
quzah, if I declare p as char *p;, will I still be able to...
Hi all,
I'm new to this board. I've had some forgotten experience with C, but now I'm refreshing.
I've always viewed string input in C as a great limitation on my programmes, because you have to...