Daim2604 1 Report post Posted July 18, 2013 Salam dan selamat sejahtera, Pertama sekali saya minta maaf kalau salah section. Saya nak tnye pasal c programming, ni code sy : #include <stdio.h> #include <conio.h> int main() { int i = 0b11111111; printf("%i", i); getch(); } sepatutnya kalau saya run code nya saya akan dapat jawapan 255 tapi saya dapat error invalid suffix "b11111111" on integer constant .. sy pakai Code Block 12.11 .. minta bantuan rakan2 , saya masih baru dalam bidang c programming, dan memang minat dalam bidang2 code2 ni .. Thanks ye.. Quote Share this post Link to post Share on other sites
syahmixp 44 Report post Posted July 18, 2013 wslm Compiler tak support kot... Codeblocks 12.11 tu guna compiler apa version berapa? Quote Share this post Link to post Share on other sites
Daim2604 1 Report post Posted July 18, 2013 wslm Compiler tak support kot... Codeblocks 12.11 tu guna compiler apa version berapa? saya x pasti plak bang, maaf sngt2 sy nie baru lagi , sy ni pun belajar sndiri je main langgar je.. tapi kalau x salah sy GCC , ni saya petik dari webpage code block GCC compiler and GDB debugger from TDM-GCC(version 4.7.1, 32 bit). Ke code block ni x bagus ? ada yang lebih baik ke? Quote Share this post Link to post Share on other sites
syahmixp 44 Report post Posted July 18, 2013 rasanya binary constant tu yang tak standard, saya try kat compiler vstudio2010 pun xleh... int i = 0b11111111; eloklah tukar jadi int i 0xff; atau yang serupa... int i = 255.. Quote Share this post Link to post Share on other sites
Daim2604 1 Report post Posted July 18, 2013 hoho, banyak lagi rupanya yang saya x blajar lgi , 0xff pun ada? , apa nama untuk function 0xff ni ye?? thanks , maaf ye menganggu Quote Share this post Link to post Share on other sites
NeoLogy 74 Report post Posted July 18, 2013 tukar printf("%i",i) kepada printf("%d",i) Quote Share this post Link to post Share on other sites
Daim2604 1 Report post Posted July 18, 2013 tukar printf("%i",i) kepada printf("%d",i) Thanks untuk reply , tpi maaf, sy dh cuba tpi x menjadi , error yang sama kluar.. Quote Share this post Link to post Share on other sites
syahmixp 44 Report post Posted July 18, 2013 (edited) 0xff ni hexadecimal.... 0xff (hex) = 255 (decimal) = 1111 1111 (binary) kalau dari binari ke hexadecimal, 4 bit/1111 = 0xf 8 bit/1111 1111 = 0xff nombor2 hexadecimal ni ada nombor biasa 0-9 pastu tambahan a-f, kira base 16...: 0 1 2 3 4 5 6 7 8 9 a b c d e f lepas f akan jadi 10, kemudian 11,12,13,14,15,16,17,18,19,1a,1b,1c,... boleh rujuk internet kalau nak faham lebih lanjut... btw binary constant memang tak standard... jadi kebanyakan compiler tak boleh compile, version gcc tertentu je ada extension untuk support binary constant ni... Edited July 18, 2013 by syahmixp Quote Share this post Link to post Share on other sites
Daim2604 1 Report post Posted July 18, 2013 0xff ni hexadecimal.... 0xff (hex) = 255 (decimal) = 1111 1111 (binary) kalau dari binari ke hexadecimal, 4 bit/1111 = 0xf 8 bit/1111 1111 = 0xff nombor2 hexadecimal ni ada nombor biasa 0-9 pastu tambahan a-f, kira base 16...: 0 1 2 3 4 5 6 7 8 9 a b c d e f lepas f akan jadi 10, kemudian 11,12,13,14,15,16,17,18,19,1a,1b,1c,... boleh rujuk internet kalau nak faham lebih lanjut... btw binary constant memang tak standard... jadi kebanyakan compiler tak boleh compile, version gcc tertentu je ada extension untuk support binary constant ni... Terima kasih banyak2 bang , sy ingatkan binary dengan decimal je yang ada, huhu , cetek nya ilmu saya , thanks bnyk2 ye yg sudi tolong juga.. Quote Share this post Link to post Share on other sites
NeoLogy 74 Report post Posted July 18, 2013 binary biasanya banyak digunakan dalam firmware coding. Most embedded C compiler biasanya support binary constant. Untuk application computer xbanyak support binary constant. Better pakai decimal atau hexadecimal. Octadecimal penah dengar? Quote Share this post Link to post Share on other sites
Daim2604 1 Report post Posted July 18, 2013 saya baru nak belajar benda tu , tapi sangkut dekat binary ni ,hehe .. minta maaf, boleh tak sapa2 terangkan skit pada sy , hexadecimal & octadecimal ni ni apa? decimal ni saya rasa saya faham , die ni nombor biasa kan? Thanks dan maaf ye Quote Share this post Link to post Share on other sites
syahmixp 44 Report post Posted July 18, 2013 nah tengok video?... http://www.youtube.com/watch?v=5sS7w-CMHkU hehe Quote Share this post Link to post Share on other sites
Daim2604 1 Report post Posted July 18, 2013 nah tengok video?... http://www.youtube.com/watch?v=5sS7w-CMHkU hehe Terima kasih ye bang, maaf kalau saya ganggu abg..thanks bnyk2.. Quote Share this post Link to post Share on other sites
umarzuki 78 Report post Posted July 20, 2013 boleh saya tau asal kod tu (dapat dari mana)? daim, ko belajar sendiri programming ke? Quote Share this post Link to post Share on other sites
Daim2604 1 Report post Posted July 25, 2013 (edited) boleh saya tau asal kod tu (dapat dari mana)? daim, ko belajar sendiri programming ke? Maaf lambat bang. Saya tngk tutorial di youtube mcm tu je. Tapi susah sikit tngk tutorial ni , tmpat bertanya tak de..hehe. Kod tu pun sy dapat dari user buat tutorial tu , skjap ye sy letak video skli , https://www.youtube.com/watch?v=6_1AWHz4RRY dkat situ la sy tngk tutorial, tpi video nye pun x banyak nanti mungkin kene pindah cari tutorial lain plak Edited July 25, 2013 by Daim2604 Quote Share this post Link to post Share on other sites