c - Segmentation Fault? getc function and arrays -


I am trying to write a program to compile with Xeon Phi and it says that there is a partition error ? I think that when I try to fill ARAC with the getc function I have written this code in many different formats, and I think it is not the most efficient, but I need to see if This will work by parallel to it

  #include & lt; Stdio.h & gt; # Include & lt; Stdlib.h & gt; #include & lt; String.h & gt; # Include & lt; Time.h> # Include & lt; Sys / types.h & gt; # Include & lt; Sys / stat.h & gt; # Include & lt; Fcntl.h & gt; // # include & lt; Omp.h & gt; Int main () {struct stat buf1; Structure state buf2; File * FP1, * FP2; Int C1, C2; Clock_t has passed; Four fname1 [40], fname2 [40]; Printf ("Enter the first file name:"); Fgets (fname1, 40, stdin); While (fname1 [strlen (fname1) - 1] == '\ n') {fname1 [strlen (fname1) -1 '=' 0 '; } Printf ("Enter the second file name:"); Fgets (fname2, 40, stdin); While (fname2 [strlen (fname2) - 1] == '\ n') {fname2 [strlen (fname2) -1 '=' 0 '; } Fp1 = fopen (fname1, "rb"); If (fp1 == NULL) {printf ("can not open% s for reading \ n", fname1); Exit (1); } Fp2 = fopen (fname2, "rb"); If (fp2 == faucet) {printf ("can not open% s for reading \ n", fname2); Exit (1); } State (fname1, and buf1); Size_t size1 = buf1.st_size; State (fname2, and buf2); Size_t size2 = buf2.st_size; Printf ("File Size 1:% zd \ n", Size 1); Printf ("File size 2:% zd \ n", size 2); Passed = clock (); // start time size_t smallest = 0; If (size 1 else lieutenant; size 2) {smallest = size 1; } And {smallest = size 2; } Printf ("lowest value:% zu \ n", smallest); Size_t i, j, k; Size_t data [smallest]; Size_t arry1 [smallest]; Size_t arry2 [smallest]; Unsigned long counter = 0; For (i = 0; i & lt; small; i ++) {data [i] = 1; Arry1 [i] = getc (fp1); Arry2 [i] = getc (fp2); } // # for pragma omp // short for (+: counter) (k = 0; k   

Thank you for your help in advance!

You can not declare an array with a size that compilation is not known at the time :

  small; Smallest = .... // some calculation size_t data [smallest]; // this is wrong!   

In order to accomplish this malloc () must use :

  size_t * data; Smallest = ... // Whatever data = Molok (smallest size * (size_T));    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -