Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>for(i=0;i&lt;Nk*4;i++) { scanf("%x",&amp;Key[i]); } </code></pre> <p>Before getting the filename, you must consume the newline from the stdin. While entering the digits, you enter 1 hex digit per line. So after reading all the Nk*4 digits, there is a newline which is waiting to be consumed. The next statement to get the newline is <code>gets</code> function. It assumes that it has read the filename. The filename obviously does not exist because its empty. The fix is to consume the newline before getting the filename(See snippet)</p> <p>I am not sure what kind of operations <code>Key</code> undergoes. But it must be a <code>unsigned int</code> if it is going to accept hex digits. <code>gets</code> is not recommended. Use <code>fgets</code> instead.</p> <p>Here's a sample snippet you <em>could</em> have posted.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;string.h&gt; int main(void) { unsigned int hex[32]={0} ; char line[BUFSIZ] = ""; char filename[64] = ""; int i; printf("Enter 4 hex digits:"); for (i = 0; i &lt; 4; ++i) { printf("&gt;"); scanf("%x", &amp;hex[i]); } printf("The hex digits are:"); for (i = 0; i &lt; 4; ++i) printf("%x", hex[i]); /* Consume newline */ fgets(line, sizeof line, stdin); printf("Enter filename with full path"); if (fgets(filename, sizeof filename, stdin)) { size_t len = strlen(filename); /* has a newline in the end */ filename[len - 1] = '\0'; printf("Filename was %s\n", filename); } else { puts("Cannot read filename"); } return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload