Selamat datang di ForSa! Forum diskusi seputar sains, teknologi dan pendidikan Indonesia.
0 Anggota dan 2 Pengunjung sedang melihat topik ini.
#import <Foundation/Foundation.h>int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSLog(@"Hello, World!"); [pool drain]; return 0;}
Memory allocation in C:Kode: [Pilih]char *ptr = "foo";/** * set_string_ptr: * @p: string to be copied into @ptr * * This will safely copies string from @p to @ptr with proper * memory allocation with use native malloc() function. */voidset_string_ptr (const char *p){ ptr = (char*) malloc (strlen (p)); strcpy (ptr, p);}
char *ptr = "foo";/** * set_string_ptr: * @p: string to be copied into @ptr * * This will safely copies string from @p to @ptr with proper * memory allocation with use native malloc() function. */voidset_string_ptr (const char *p){ ptr = (char*) malloc (strlen (p)); strcpy (ptr, p);}
ptr = (char *)malloc(strlen(p) + 1); if (ptr != NULL) { /* lakukan strcpy bila alokasi berhasil dilakukan */ strcpy(ptr, p); }
ahmad:secara teori saya cukup paham omhanya saja pada prakteknya sy ga ngertipake software apa bn database sm terutama etlnyamsh newbie om
Hay,...boleh dong,..aku juga pengen belajar pemrograman C...dikit2 lagi belajar micro ocontroller nih,...makasih,...
ajarin perl donk
Yang satu ini PHP:Kode: [Pilih]<?php/** Ohhh... ternyata situs forsa juga pakai PHP **//** Contoh definisi variabel **/$say_yes = "Yes...";/** Contoh definisi constant **/define ('__MY_CONSTANT__', 'this is constant...');/** Contoh statement dengan keyword "if" **/if (defined('__MY_CONSTANT__')){ print __MY__CONSTANT__ . "\n";} else { print "__MY_CONTANT__ constant is undefined...\n";}/** Contoh fungsi print, identik dengan fungsi echo **/print $say_yes; // This will output - Yes.../** * Contoh deklarasi fungsi bebas (non-OO) */function function_name ($param1, $param2, $optional = true){ // Add some codes here...}/** * Contoh deklarasi class - PHP4 style */class My_Class { /** Class field member **/ var $field_example; /** Constructor, PHP4 Style **/ function My_Class ($param) { // Intializations are here... $this->field_example = $param; } /** access function **/ function get_field_ex_value () { return $this->field_example; } }/** * Contoh deklarasi class - PHP5 style */class My_Class_PHP5 { /** Class field member - private **/ private $_priv_field; /** Class filed member - public **/ public $pub_field; /** Constructor, PHP5 Style **/ function __construct ($param1, $param2) { // Intializations are here... $this->_priv_field = $param1; $this->pub_field = $param2; } /** public access function **/ public final function get_priv_field_value () { return $this->__get_priv_field(); } /** public access function **/ public final function get_priv_field_value () { return $this->pub_field; } /** private access function **/ private function __get_priv_field() { return $this->_priv_field; } }/** Defining array variable **/$my_array = array ("Richard M. Stallman", "Rasmus Redlof", "Larry Walls", "Linuz B. Thorvalds");/** Loop with use "foreach" keyword **/foreach ($my_array as $entry){ print "$entry\n";}/** Loop with "for" keyword **/for ($i = 0; $i < count($my_array); $i++){ print $my_array[$i] . "\n";}/** Loop with "do" and "while" keyword **/$count = 0;do { print $my_array[$count] . "\n"; $count++;} while ($count < count($my_array)-1);
<?php/** Ohhh... ternyata situs forsa juga pakai PHP **//** Contoh definisi variabel **/$say_yes = "Yes...";/** Contoh definisi constant **/define ('__MY_CONSTANT__', 'this is constant...');/** Contoh statement dengan keyword "if" **/if (defined('__MY_CONSTANT__')){ print __MY__CONSTANT__ . "\n";} else { print "__MY_CONTANT__ constant is undefined...\n";}/** Contoh fungsi print, identik dengan fungsi echo **/print $say_yes; // This will output - Yes.../** * Contoh deklarasi fungsi bebas (non-OO) */function function_name ($param1, $param2, $optional = true){ // Add some codes here...}/** * Contoh deklarasi class - PHP4 style */class My_Class { /** Class field member **/ var $field_example; /** Constructor, PHP4 Style **/ function My_Class ($param) { // Intializations are here... $this->field_example = $param; } /** access function **/ function get_field_ex_value () { return $this->field_example; } }/** * Contoh deklarasi class - PHP5 style */class My_Class_PHP5 { /** Class field member - private **/ private $_priv_field; /** Class filed member - public **/ public $pub_field; /** Constructor, PHP5 Style **/ function __construct ($param1, $param2) { // Intializations are here... $this->_priv_field = $param1; $this->pub_field = $param2; } /** public access function **/ public final function get_priv_field_value () { return $this->__get_priv_field(); } /** public access function **/ public final function get_priv_field_value () { return $this->pub_field; } /** private access function **/ private function __get_priv_field() { return $this->_priv_field; } }/** Defining array variable **/$my_array = array ("Richard M. Stallman", "Rasmus Redlof", "Larry Walls", "Linuz B. Thorvalds");/** Loop with use "foreach" keyword **/foreach ($my_array as $entry){ print "$entry\n";}/** Loop with "for" keyword **/for ($i = 0; $i < count($my_array); $i++){ print $my_array[$i] . "\n";}/** Loop with "do" and "while" keyword **/$count = 0;do { print $my_array[$count] . "\n"; $count++;} while ($count < count($my_array)-1);
ajarin buat program trigonometri donk, pake apa aja boleh,...dari tahun lalu, nggak tahu prosesnya gimana!
Kutip dari: utusan langit pada April 11, 2009, 05:31:45 PMajarin buat program trigonometri donk, pake apa aja boleh,...dari tahun lalu, nggak tahu prosesnya gimana!Saya bisa bantu, mau mulai darimana? Perhitungannya?
kenapa mempelajari bahasa pemograman saat melihatnya bikin pusing?? tetapi setelah dipelajari kelihatan lebih gampang?? seperti saya mempelajari vb6, ketika pertama kali melihatnya masih ingat saya "kata orang" bahasa basic tu lebih mudah dimengerti karena bahasanya masih menggunakan bahasa manusia, tetapi saat melihatnya, sederet kata-kata aneh yang terlihat.. tetapi setelah terbiasa saya enjoy saja melihat hal seperti itu..
g ah kk...bhsa asembler yah bhsa asemblerg da mirip" nya ma bhasa mandarin..