Hot answers tagged

2

Get rid of the semicolon on line 6. A semicolon there marks the line as a function signature. You'll learn more about that later.


1

simple answer. You can't. That's because a string is a collection of sequential chars. Each char can be accessed as if it was in an array. For example, say you had string mystring. Then the third char in the string would be mystring[2].


1

The code is generating a seg fault. Look at the following code: if (key == 0) { fclose(img); } If this code is supposed to detect that a file has already been opened, shouldn't it be key > 0 ? Weren't you seeing the seg fault when you ran the code? If this answers your question, please click on the check mark to accept. ...


1

Looks like you've got a typo in the signature checking section. you've got && (buffer[3] & 0xe0) == 0xe0) when you should have && (buffer[3] & 0xf0) == 0xe0) you have an e where you should have an f. try changing that and see if you have an improvement


Only top voted, non community-wiki answers of a minimum length are eligible