I have a char variable, and I am attempting to make it into an int. After searching online, people mentioned I should do the following:
char t;
int time = t - '0';
After doing this I get a Run-Time Check failure. What is the reason for this?
Thanks in advance.
When you enter one character, two characters then get written into the memory, because when you write to a memory location using scanf and the %s format specifier, a terminating zero value is added. You are trying to store two characters in a single char variable. This is bad.
The bad solution here is for you to make t an array of char, rather than a single char.
The better solution is to use C++ strings and C++ IO (e.g. cin ).
Another thing, please don't start a new topic about the same subject and double posting questions. You could be reported and your account restricted. The reason for this is that it is ultimately a time waster for us, the same advice is given for both topics.
In above code, the file is opened using fopen() in text mode.
For a wav file you should open it in binary mode.
In order to open a file as a binary file, a "b" character has to be included in the mode string. This additional "b" character can either be appended at the end of the string (thus making the following compound modes: "rb", "wb"