[Dev-C++] Help me.... strange char functions on MinGW
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Rafael O. L. <raf...@gm...> - 2008-08-02 18:17:23
|
Hi All.
I'm learning C with Dev-C++ and MinGW and a wrote such function like this:
#include <stdio.h>
char *strset(char *s, char ch);
main()
{
printf("%s", strset("TEST, TEST", 'c') );
getchar();
}
char *strset(char *s, char ch)
{
int i;
for(i = 0; s[i]; i++)
s[i] = ch;
return s;
}
that would have to fill the string argument with the char ('c') and print
it.
string: "TEST, TEST"
result: "**************"
But, I have a Access Violation, and program crashes.
I've tried to compile in LCCWin32 and runs fine.
Then, I've tried, again, to compile in mingw and ran on MSYS, suprise....
works fine too.
But in a DOS shell, the same mingw compiled program gives me a Access
Violation... Why!!!!????
Please Help...
--
Rafael Oliveira de Lima
Técnico Eletrônico - Projectus NDT.
Programador Junior e Depurador Assembly em Arquiteturas RISC Microchip 8
bits.
(famílias PIC12*, PIC14*, PIC16* e PIC18*).
|