Hi,
After medding around with C, linux, (and a little bit of sockets), I've realize that I'm always taking things for granted.
It takes so much work to write a proper and solid application. You...
Type: Posts; User: stevong
Hi,
After medding around with C, linux, (and a little bit of sockets), I've realize that I'm always taking things for granted.
It takes so much work to write a proper and solid application. You...
Hi,
I happened to read up on some nix sockets and I'm kinda hooked.
The sample scripts often mentioning about zero-ing up the structs of sockaddr_in.
memset(&(my_addr.sin_zero), ’\0’,...
You meant, something similiar to this? My struct has a member int which auto increment by one...
node *GetNode(int idx)
{
node *curr = NULL;
curr=LastNode;
while(curr)
My concepts on memory alloc and pointers are still totally screwed. Im confusing myself at times. (I feel guilty posting all these threads at times)
Ok, here's the oringinal show all nodes, which...
*blushed*
I often used trial and error to venture into new territories and trying out new stuffs. =p My luck indeed ran out. haha.
I've used pointer to pointer because
**ptr is the same as...
But truth hurts: Not everyone is a child prodigy....
I came up with something "similiar". And it works fine. Im puzzled.
person **testing()
{
person **test;
test[0] = malloc(sizeof(person));
test[1] = malloc(sizeof(person));
...
Thanks Salem and Quzah :)
After some reading up, I came out with the following:
node **ShowAllNodes()
{
node *curr = NULL;
node **RtnValues=NULL;
But I can't seems to iterate through it.
What I intend to do is have a function that will loop through the linked list; collect all the structs and store them in an array.
This function will...
Hi,
Let's say I have an array of structs.
How do I move through the array to retrieve the next struct in list?
Please advise. Thanks :)
Yes I do.
The intention of this thread is to hope that someone can break down that single line of code into simpler statements in which layman/newbies can understand. :)
Thanks to ...
Haha. yea. I didnt read his post clearly.
I almost fell off my chair when I read his post all over again.
Thanks. That's sweet.:)
EDIT: What are you trying to say?
Dear experts,
I was browsing through the FAQs when I stumbled on one portion:
int leap_year ( int year )
{
return year % 4 == 0 && ( year % 100 != 0 || year % 400 == 0 );
}
oh ok..Hmm...I just wrote and tested this and it seems fine in my outputs.
it managed to clear unwanted buffer (the extra buffer that exceeded the desire char length) and the irritating \n at end of...
Oh ok. Thanks! I shall play with it again.
But about backspaces '\b'?
Are \b being taken in also? And what about tabs '\t' ?
Are they considered to be one character also?
Sorry. Im still a bit upset over input validation.
Consider the following:
fgets(BUF,10,stdin);
BUF is supposed to take in 10 chars. But only 9 chars will be readable by us. Since the...
:eek: LOL. Silly me. Got it. I got what you meant. :p
I'll try again.
This looks better :D
int PartialFind(char *f)
{
Hi. It's me again. Can anyone figure why the first code listing, doesnt work despite passing in the correct values?
Whereas if I hardcode the values in the 2nd listing, it works.
:confused:
...
Oh yes. You r right. :D. The \n is causing the problem.
Managed to solve the "double execution" by using
while(fgetc(stdin)!='\n');
i used -'0' because i want to cast the char back to int...
Sorry. Topic should read fgetc() instead of fgets()
Hi Guys,
Im trying out C inputs. But the following code seems to be running out of expectations.
When the program runs, it asked for 1,2,3. I entered 1. It should print out "1". Then asking me...
Hmm. So that using printf("%s",c[0]) will out put ".-", printf("%s",c[1]) will out put "-..."; in which they are the morse rep of the alphabets....
37 is because..26 alphabets, plus 10 numbers?...
I've rewrote the whole thing. Based on my shallow understanding of dynamic memory alloc and pointers. (hopefully)
Learning C is not a bed of roses... :(
Please help me... :( Thanks..
1. I...