I have mini program in C. Dev C++ compile but .exe file does not work in DOS terminal. I test with Borland compiler 5.5 version with no problem. Please check my program.
OS: WIN 8.1
Thank you
Ahmet
/***** my program *****/
include <stdio.h>
include <stdlib.h>
include <string.h>
/ run this program using the console pauser or add your own getch, system("pause") or input loop /
In practise, GCC is behaving as expected because:
1.) You are actually manipulating constants.
2.) GCC doc on warning messages switches teach us :
(refer to https://gcc.gnu.org/onlinedocs/gcc-3.0/gcc_3.html )
QUOTE
-Wwrite-strings
Give string constants the type const char[length] so that copying the address of one into a non-const char * pointer will get a warning. These warnings will help you find at compile time code that can try to write into a string constant, but only if you have been very careful about using const in declarations and prototypes. Otherwise, it will just be a nuisance; this is why we did not make `-Wall' request these warnings.
END QUOTE
A possible (trivial?) solution could be:
char p1[32] = "missi,ssi pi"; // length is now your new problem...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I have mini program in C. Dev C++ compile but .exe file does not work in DOS terminal. I test with Borland compiler 5.5 version with no problem. Please check my program.
OS: WIN 8.1
Thank you
Ahmet
/***** my program *****/
include <stdio.h>
include <stdlib.h>
include <string.h>
/ run this program using the console pauser or add your own getch, system("pause") or input loop /
int main(int argc, char *argv[]) {
}
I found the reason , char p1,p2,*p3 are constant declarations (C99) but after compiling no warning !
Last edit: Ahmet 2015-05-05
In practise, GCC is behaving as expected because:
1.) You are actually manipulating constants.
2.) GCC doc on warning messages switches teach us :
(refer to https://gcc.gnu.org/onlinedocs/gcc-3.0/gcc_3.html )
QUOTE
-Wwrite-strings
Give string constants the type const char[length] so that copying the address of one into a non-const char * pointer will get a warning. These warnings will help you find at compile time code that can try to write into a string constant, but only if you have been very careful about using const in declarations and prototypes. Otherwise, it will just be a nuisance; this is why we did not make `-Wall' request these warnings.
END QUOTE
A possible (trivial?) solution could be:
char p1[32] = "missi,ssi pi"; // length is now your new problem...