Re: [Dev-C++] Help me.... strange char functions on MinGW
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: Eric <eri...@wo...> - 2008-08-02 21:42:17
|
rats!! I forgot to tell you I changed printf("%s", strset("TEST, TEST", 'c') ); to printf("%s", "TEST, TEST", 'c' ); that is why I thought "there is bound to be a question two" ======> Note the file size of this EMail!!! <======= compared to the last two >From Eric ----- Original Message ----- From: Eric To: Rafael Oliveira Lima ; dev...@li... Sent: Sunday, August 03, 2008 9:09 AM Subject: Re: [Dev-C++] Help me.... strange char functions on MinGW yes well I got a "this program has performed an illegal operation and will shut down" untill I changed main() to int main() in theory it should go int main(int argc, char *argv[]) with a return 0; or maybe something else at the end of the main function the group looks forward to question two on this project try this #include <stdio.h> #include <cstdlib> #include <iostream> char *strset(char *s, char ch); int main() { printf("%s", "TEST, TEST", 'c' ); getchar(); system("PAUSE"); return EXIT_SUCCESS; } char *strset(char *s, char ch) { int i; for(i = 0; s[i]; i++) s[i] = ch; return s; } If you are going to do HTML EMail, do it with class >From Eric ----- Original Message ----- From: Rafael Oliveira Lima To: dev...@li... Sent: Sunday, August 03, 2008 6:17 AM Subject: [Dev-C++] Help me.... strange char functions on MinGW 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*). |