Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. int** readFile(char* filename){
  2.  
  3. int col=0, row =0;
  4. int i=0;
  5. int* numList[2048];
  6.  
  7. for(int i = 0; i<2048; i++)
  8. numList[i] = (int*) malloc(6*sizeof(int));
  9.  
  10. if(NULL == numList){
  11.  
  12. printf("Memory error!");
  13.  
  14. }
  15.  
  16. char * token = NULL;
  17.  
  18. char currentLine[25] = {''};
  19.  
  20. FILE* file = fopen(filename, "r");
  21.  
  22. if(NULL != file){
  23.  
  24. printf("File is opened successfullyn");
  25.  
  26. if( NULL != fgets (currentLine, 60, file) )
  27. {
  28. int i = 0;
  29. while (NULL != currentLine[i]){
  30.  
  31. printf("%d ", currentLine[i]);
  32. i++;
  33. }
  34. }
  35. }
  36. else
  37. {
  38. printf("File I/O Error");
  39. return NULL;
  40. }
  41.  
  42. fclose(file);
  43.  
  44. return numList;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement