Hi All. I am new to C++, infact I started watching tutorials just about an hour ago. But, I had some experiece of Javascript, PHP, so It is fine.
Now, my question is that, I am untimately, learning C++ to be able to manipulate a .wav files, just to write a script from scratch and be able to read file, and illustrate in a graphical interface like a spectrogram.
But, since I am a newbie, I decided to start learning about reading binary files first, and actually used a code from this website http://www.cplusplus.com/reference/istream/istream/read/ to read a simple [code]test.txt[/code] file, which I wrote my name in, and runned the code
// read a file into memory
#include <iostream> // std::cout
#include <fstream> // std::ifstream
int main () {
std::ifstream is ("test.txt", std::ifstream::binary);
if (is) {
// get length of file:
is.seekg (0, is.end);
int length = is.tellg();
is.seekg (0, is.beg);
char * buffer = new char [length];
std::cout << "Reading " << length << " characters... ";
// read data as a block:
is.read (buffer,length);
if (is)
std::cout << "all characters read successfully.";
else
std::cout << "error: only " << is.gcount() << " could be read";
is.close();
// ...buffer contains the entire file...
delete[] buffer;
}
return 0;
}
and It gave me, a message saying [code]Reading 32 characters... all characters read successfully.
[/code] even though, I only had like 29 characters in there. Anyway, that is not the problem.
The problem, is that, I placed a .wav file at the place where it said test.txt and even placed the .wav file in the same directory, and when I ran the code, it does not give me error or success, it shell just says, "Process returned 0 (0x0) execution time 0.008s"
What am I doing wrong? I just want to read the contents of what is in that wav file only? Be it in a frequency/amplitude/sound wave whatever the term is. Why is it not show