Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

My OO...

Name: Anonymous 2011-12-13 3:19

...it's violated!

http://programmers.stackexchange.com/questions/17031/when-c-handles-pop-in-your-c-code-and-break-your-pretty-oo-design

Anime avatar. Passive-aggressive rant. Autismal as fuck. That's gotta be someone from /prague/, amirite?

Name: Anonymous 2011-12-15 20:38

>>59
In C, you can't.  You have to explicitly type-cast or you get a compiler error.
int main()
{
    char * x;
    x = 5;
    x = "Hello";
    return 0;
}


GCC:
Compiling: main.c
main.c: In function 'main':
main.c:4: warning: assignment makes pointer from integer without a cast
Linking console executable: bin\baka1.exe
Output size is 25.11 KB
0 errors, 1 warnings


OpenWatcom:
Compiling: main.c
main.c(4): Warning! W101: Non-portable pointer conversion
main.c(4): Note! N2003: source conversion type is 'int '
main.c(4): Note! N2004: target conversion type is 'char *'
Linking console executable: bin\baka2.exe
Output size is 32.01 KB
0 errors, 3 warnings


Digital Mars:
Compiling: main.c
    x = 5;
         ^
main.c(4) : Error: need explicit cast to convert
from: int
to  : char *
--- errorlevel 1
1 errors, 0 warnings

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List