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: Codexc | February 27, 2010 @ 11:19pm
C Code
[
Download
]
#include <unistd.h> /* Symbolic Constants */ #include <sys/types.h> /* Primitive System Data Types */ #include <errno.h> /* Errors */ #include <stdio.h> /* Input/Output */ #include <stdlib.h> /* General Utilities */ #include <string.h> /* String handling */ #include <limits.h> #define NUM_THREADS 10 int BUFF_SIZE = 10; char *buffer[10]; struct thread_data{ int thread_id; int start_index; int end_index; double average; }; struct thread_data thread_data_array[NUM_THREADS]; void load_sharedbuffer(int c, char *file_name){ FILE *file; if((file = fopen(file_name, "r"))==NULL) { printf("can't open %s\n", "testinput"); exit(1); } else { int i = 0; if (buffer == NULL) perror ("Memory Error"); for(i=0; i<BUFF_SIZE; i++) { buffer[i] = (char*) calloc(sizeof(char*),80); fgets(buffer[i],79, file); } } fclose(file); /*terminate*/ } int main(int argc, char **argv) { if(argc<2) {load_sharedbuffer(argc,"testinput");} else load_sharedbuffer(argc, argv[1]); int j = 0; for(j=0; j<BUFF_SIZE; j++) printf("%s",buffer[j]); return 0; }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.33 / 8
63 Votes
http://codebin.yi.org/522
page generated in 0.01 seconds