kz_syaz 0 Report post Posted August 29, 2007 sy orang baru dalam putera.com pas tu nak tanya pasal string (c language)....boleh terangkan dengan lebih mendalam pasal string... Quote Share this post Link to post Share on other sites
encik pot pet 0 Report post Posted August 29, 2007 boleh.. boleh baca kat http://en.wikipedia.org/wiki/String_%28computer_science%29 - generalc specific - http://www.cprogramming.com/tutorial/c/lesson9.html another reference - http://www.cplusplus.com/reference/clibrary/cstring/ Quote Share this post Link to post Share on other sites
encik pot pet 0 Report post Posted August 30, 2007 kz_syaz wrote to my pm boxboleh tanya lagi???? canme nak tukarkan original code kpd encoded code guna string dlm c language?????please help me....i really need ur help original code a hingga z. encoded code {r,x,b,g,t}.contoh a diwakili oleh r.b diwakili oleh x dan seterusnya.. selepas tu... paparan yang perlu dikeluarkan ilah original ang encoded....tak bawak soalan tu. tonigh sy sent kat awk soalan yang penuh...sy dah pening pale nak buat sume tu.why the heck most of newbie forumers love to pm moderator for a direct answer? Quote Share this post Link to post Share on other sites
encik pot pet 0 Report post Posted August 31, 2007 (edited) ok lah, soalan tu lebih kurang camni,#include <stdio.h> #include <string.h> char table[] = {'r','x','b','g','t'}; void convert(char *); int main() { Â Â Â Â char* mytext="abcde"; Â Â Â Â char* mytext2="decab"; Â Â Â Â convert(mytext); Â Â Â Â printf("%s\n\n", mytext); Â Â Â Â convert(mytext2); Â Â Â Â printf("%s\n\n", mytext2); Â Â Â Â return 0; } void convert(char* text) { Â Â Â Â int len = 0; Â Â Â Â char temp = 0; Â Â Â Â len = strlen(text); Â Â Â Â while (len > 0) Â Â Â Â { Â Â Â Â Â Â Â Â temp = *text - 0x61; Â Â Â Â Â Â Â Â *text = table[temp]; Â Â Â Â Â Â Â Â *text++; Â Â Â Â Â Â Â Â len--; Â Â Â Â } } kalau nak nampak 'elegant' lagi void convert(char* text) { Â Â Â Â while (*text != 0) Â Â Â Â { Â Â Â Â Â Â Â Â *text = table[*text - 0x61]; Â Â Â Â Â Â Â Â *text++; Â Â Â Â } }pandai2 la modify utk support a to zwarning: jgn pakai mingw compiler, mungkin ada masalah. Edited August 31, 2007 by zeph Quote Share this post Link to post Share on other sites
kz_syaz 0 Report post Posted September 5, 2007 zach... nak tanya nie... cording tu ble modifykan output apa yang dimasukkan oleh programmer... masalahnya sekarang nie cording yang nak tu ouput mesti user boleh masukkan..pas tu nak tanya... tahu tak for mula untuk tukarkan ory ke encode???? yang bagi air tu tak dapat nak tukar laa bila user tang masukkan aksara. Quote Share this post Link to post Share on other sites
encik pot pet 0 Report post Posted September 5, 2007 awak ubah la utk accept string dari user. simple jer. kan lesson pertama awak dalam kelas/lecture C ialah meminta input dari user dan display balik input. takkan dah lupa kut.char text[100]={0}; printf("sila masukkan text awak: "); scanf("%s", text); convert(text);tang decode/encode tu, saya dah bagi cara encoding, apa kata awak perah sikit otak tu utk fikir menterbalikkan process. takde la kompleks sangat pun Quote Share this post Link to post Share on other sites