Note that there are some explanatory texts on larger screens.

plurals
  1. POReturning char pointer from C function
    text
    copied!<p>I need help to check if my code is correct. The code is too big to include entirely, so I will paste only the affected parts.</p> <pre><code>char *tmp; tmp=Decode_URL(tmp_data); sprintf(Data,"%s",tmp); tmp=Decode_URL(tmp_backup1); sprintf(DataB[0],"%s",tmp); tmp=Decode_URL(tmp_backup2); sprintf(DataB[1],"%s",tmp); tmp=Decode_URL(tmp_backup3); sprintf(DataB[2],"%s",tmp); tmp=Decode_URL(tmp_backup4); sprintf(DataB[3],"%s",tmp); tmp=Decode_URL(tmp_backup5); sprintf(DataB[4],"%s",tmp); </code></pre> <p>The <code>Decode_URL</code> function returns a <code>char *</code>.</p> <p>So my question is, is it correct to always use <code>tmp</code> to receive the <code>char *</code> returned by the function? Or I should create more <code>char *tmpx</code>, one for each call to <code>Decode_URL</code>?</p> <hr> <p>EDIT FOR MORE INFO:</p> <pre><code>char *Decode_URL(char *url){ char *check; check=EnDeCrypt(some vars here); return check; } char *EnDeCrypt(const char *pszText, int iTextLen, const char *pszKey) { char *cipher; int a, b, i=0, j=0, k; int ilen; int sbox[256]; int key[256]; ilen = strlen(pszKey); for (a=0; a &lt; 256; a++) { key[a] = pszKey[a % ilen]; sbox[a] = a; } for (a=0, b=0; a &lt; 256; a++) { b = (b + sbox[a] + key[a]) % 256; swapints(sbox, a, b); } cipher = (char *)malloc(iTextLen); for (a=0; a &lt; iTextLen; a++) { i = (i + 1) % 256; j = (j + sbox[i]) % 256; swapints(sbox, i, j); k = sbox[(sbox[i] + sbox[j]) % 256]; cipher[a] = pszText[a] ^ k; } return cipher; } </code></pre> <p>Thanks</p>
 

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