The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled C Code
Posted by: Docmur | June 29, 2010 @ 12:43pm
C Code
[
Download
]
#include <stdio.h> #include <stdlib.h> #include <string.h> #define _TEST typedef struct linklist{ char * cIP; struct linklist * iNext; }sList; void listAdd(sList ** Node, char * ip_address) { //Node = malloc(sizeof(Node)); if( *Node == NULL ) { /* Allocate a Node */ Node = malloc(sizeof(Node)); if( *Node == NULL ) { /* This means we couldn't allocate a Node*/ perror("malloc"); } /* Lets check exactly what happened */ perror("malloc"); } /* If we are here then we know we have allocated a Node */ strcpy((*Node)->cIP,ip_address); #ifdef _TEST printf("\nIP Address = %s",ip_address); printf("\nIP Address in Node = %s",(*Node)->cIP); fflush(stdout); fflush(stdin); #endif /* Advance the linked list */ } int main(int argc, char *argv[]) { /* What we need to do * * We need to open a file with the IP's of the servers in it * we add the IP to a Linked List we then send the command * to the server to change the password */ struct sList * List; List = malloc(sizeof(sList)); listAdd(&List, "0.0.0.0"); listAdd(&List, "0.0.0.1"); listAdd(&List, "0.0.0.2"); listAdd(&List, "0.0.0.3"); #ifdef _TEST printf("\nI've come back from List Add"); fflush(stdout); fflush(stdin); getc(stdin); #endif free(List); List = NULL; exit(0); }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.55 / 8
44 Votes
http://codebin.yi.org/720
page generated in 0.01 seconds