I have the following code
#include <iostream>
#include <cstdio>
volatile char s[7] = "test";
int main() {
std::cout << s << std::endl;
std::printf("%s\n", s);
}
It prints "1" with std::cout and "test" with std::printf. Why does it print "1" for the first case?! My system is "Linux debian 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u5 (2017-09-19) x86_64 GNU/Linux", my C++ compiler is "g++ (GCC) 7.3.0".
If I remove "volatile" keyword then std::cout prints the expected "test".