Pikir dan Rasa

cogito ergo sum

Posts Tagged ‘c

“Write in C” song [Dennis Ritchie, in memoriam]

leave a comment »

When I find my code in tons of trouble,
Friends and colleagues come to me,
Speaking words of wisdom:
“Write in C.”
As the deadline fast approaches,
And bugs are all that I can see,
Somewhere, someone whispers:
“Write in C.”
Write in C, Write in C,
Write in C, oh, Write in C.
LOGO’s dead and buried,
Write in C.
I used to write a lot of FORTRAN,
For science it worked flawlessly.
Try using it for graphics!
Write in C.
If you’ve just spent nearly 30 hours
Debugging some assembly,
Soon you will be glad to
Write in C.
Write in C, Write in C,
Write in C, yeah, Write in C.
Only wimps use BASIC.
Write in C.
Write in C, Write in C
Write in C, oh, Write in C.
Pascal won’t quite cut it.
Write in C.
Write in C, Write in C,
Write in C, yeah, Write in C.
Don’t even mention COBOL.
Write in C.
(and what about C++ ?)

Written by sunupradana

February 28, 2012 at 8:57 am

Posted in Komputer, Technology

Tagged with ,

Ukuran dari variabel (datatypes) pada Arduino

leave a comment »

Berikut adalah kode hasil modifikasi dari kode pada sizes.c [ref], yang disesuaikan khusus untuk sistem Arduino. Untuk mendapatkan hasilnya kita perlu mengaktifkan “Serial Monitor”.


 Modifikasi dari sizes.c


void setup() {

  Serial.print("Bytes per char          : "); Serial.println((sizeof(char)));
  Serial.print("Bytes per unsigned char : "); Serial.println((sizeof(unsigned char)));
  Serial.print("Bytes per short         : "); Serial.println(sizeof(short));
  Serial.print("Bytes per unsigned short: "); Serial.println(sizeof(unsigned short));
  Serial.print("Bytes per int           : "); Serial.println(sizeof(int));
  Serial.print("Bytes per unsigned int  : "); Serial.println(sizeof(unsigned int));
  Serial.print("Bytes per long          : "); Serial.println(sizeof(long));
  Serial.print("Bytes per unsigned long : "); Serial.println(sizeof(unsigned long));
  Serial.print("Bytes per float         : "); Serial.println(sizeof(float));
  Serial.print("Bytes per double        : "); Serial.println(sizeof(double));
  Serial.print("Bytes per long double   : "); Serial.println(sizeof(long double));
  Serial.print("Bytes per size_t        : "); Serial.println(sizeof(size_t));

void loop() {







Written by sunupradana

February 16, 2012 at 2:52 pm

The Essentials of C Programs [link ke kutipan Sams Teach Yourself C in 24 Hours]

leave a comment »

Sams Teach Yourself C in 24 Hours

Hour 3 – The Essentials of C Programs


The whole is equal to the sum of its parts.


In Hour 2, “Writing Your First C Program,” you saw and wrote some simple C programs. You also learned about the basic structure of a C program. You know that a program written in C has to be compiled before it can be executed. In this lesson you’ll learn more essentials within a C program, such as

  • Constants and variables
  • Expressions
  • Statements
  • Statement blocks
  • C function types and names
  • Arguments to functions
  • The body of a function
  • Function calls


Link>> http://web.iku.edu.tr/courses/cs/eng001/

Written by sunupradana

January 14, 2012 at 6:36 pm

Posted in Komputer

Tagged with , ,

Penggunaan define atau const pada bahasa C (perbedaan dengan C++ / CPP)

with one comment

Salah satu kemudahan menggunakan sistem Arduino adalah karena sekalipun terinspirasi dari bahasa Processing, bahasa Arduino yang dipergunakan pada sketch berasal dari C++. Kita bisa mencoba alur logika pemrograman (algoritma) pada banyak kompiler C&C++. Lebih dari itu kita juga bisa memanfaatkan IDE untuk kompiler C/C++, misalnya Codelite, Code::Blocks atau Geany.

Read the rest of this entry »

Written by sunupradana

January 7, 2012 at 6:53 pm

Ideone.com | Online IDE & Debugging Tool >> C/C++, Java, PHP, Python, and 40+ compilers and intepreters

leave a comment »

What is ideone?
Ideone is something more than a pastebin; it’s an online compiler and debugging tool which allows
to compile and run code online in more than 40 programming languages.

How to use ideone?
Choose a programming language, enter your source code and input data into text boxes. Then check or uncheck run code (whether to execute your program) and private (whether not to list your code in the recent codes page) checkboxes, click the submit button and watch your snippet being executed.

Having problems?
Check the samples to see how to write a properly working code. To find out more, see the help section or the FAQ page.

Footer: Autoposted dengan [ email ] dari [ sunu’s posterous ]

Written by sunupradana

January 6, 2012 at 6:02 pm

Online programming, code test [codepad]

leave a comment »

codepad is an online compiler/interpreter, and a simple collaboration tool.
Paste your code below, and codepad will run it and give you a short URL you can use to share it in chat or email.



Footer: Autoposted dengan [ email ] dari [ sunu’s posterous ]

Written by sunupradana

January 6, 2012 at 5:29 pm

Const Correctness – C++ Tutorials – Cprogramming.com

leave a comment »

Const Functions

The effects of declaring a variable to be const propagate throughout the program. Once you have a const object, it cannot be assigned to a non-const reference or use functions that are known to be capable of changing the state of the object. This is necessary to enforce the const-ness of the object, but it means you need a way to state that a function should not make changes to an object. In non-object-oriented code, this is as easy as using const references as demonstrated above.

In C++, however, there’s the issue of classes with methods. If you have a const object, you don’t want to call methods that can change the object, so you need a way of letting the compiler know which methods can be safely called. These methods are called “const functions”, and are the only functions that can be called on a const object. Note, by the way, that only member methods make sense as const methods. Remember that in C++, every method of an object receives an implicit this pointer to the object; const methods effectively receive a const this pointer.

The way to declare that a function is safe for const objects is simply to mark it as const; the syntax for const functions is a little bit peculiar because there’s only one place where you can really put the const: at the end of the function:

Footer: Autoposted dengan [ email ] dari [ sunu’s posterous ]

Written by sunupradana

December 31, 2011 at 4:28 pm

Posted in Engineering, Komputer

Tagged with , ,