July 28, 201015 yr comment_1043254 ade x yg sudi membantu? urgent...kene siapkn minggu ni gak mcm mane nk convert output dr cout of the 1st process jadi input for the next process? kerjasama tuan/puan/cik amat dhargai dulu ms blaja kt u,pnah blaja c++ tu pn 1st semester aku dpt c+ hampeh kalaula nama program tu A++ msti aku dpt A+ gak hehe yang aku gune nie compile using linux fendora coding kt bwh ni bkn c++ (aku rase la) mungkin C tu pn x setel lg [quote]#include <iostream> #include <stdio> #include <string> #include <fstream> using namespace std; int main() { FILE * pFile; char mystring [100]; char tmp[100]; unsigned int x; int numchars = 60; int string_length; //read from file. pFile = fopen ("input.txt" , "r"); if (pFile == NULL) perror ("Error opening file"); else { fgets (mystring , 100 , pFile); puts (mystring); fclose (pFile); } //Measure the length of the string. string_length = strlen(mystring); //Output the last characters of the string. for(x=36;x<string_length;x++) { if (x<=numchars) cout << mystring[x]; } return 0; } [/quote] ni plak input dia dari file input.txt [quote]26/01/10 09:20:20 MAL BIN BIN275 TSTCB U8L5 O/CR ..N UCOS Operated[/quote] output dia yg appear kt output.txt [quote]BIN275 TSTCB U8L5 O/CR [/quote] lpas tu, buang white spaces dr blkg (aku rase gune command last not of) dari [quote]"BIN275 TSTCB U8L5 O/CR "[/quote] jadi [quote]"BIN275 TSTCB U8L5 O/CR"[/quote] pastu ambik 4 character dari blkg [quote]O/CR[/quote] so mintak pertolongan dari sifu2 aku.. mcm mane aku leh setelkan program aku nie..... nanti aku sponsor lunch Edited July 28, 201015 yr by shinchai86 Report
July 29, 201015 yr Author comment_1043337 Quote: Originally Posted by apis17 View Post cangih sunguh projek dier. haha.. apa input & output sebenarnya nih? & apa yg nak di akhir proses? mekasih bro nie input aku Quote: 26/01/10 09:20:20 MAL BIN BIN275 TSTCB U8L5 O/CR ..N UCOS Operated aku dah wat utk extract output dari column 36 sampai column 60 dan output skang nie Quote: BIN275 TSTCB U8L5 O/CR so, skang nie aku nak buang space yang di belakang tue dan dapatkan empat character terakthir sebagai output akhir aku. aku nak kuarkan Quote: O/CR nie yang latest program aku buat..... dah jem kepala nak pikir lagi nie... di harap bleh membantu. Quote: #include <iostream> #include <string.h> #include <fstream> using namespace std; int main() { FILE * pFile; char mystring [100]; int string_length; ofstream output; pFile = fopen ("input.txt" , "r"); output.open("output.txt", ios:: out); fgets (mystring , 100 , pFile); puts (mystring); string_length = strlen(mystring); int i=36; while (i < 60) { output<<mystring[i]; ++i; } fclose (pFile); output.close(); return 0; } jasa korang dikenang sepanjang hayat.... Report
August 7, 201015 yr comment_1044236 apsal ko suka sangat tekan enter banyak kali ni? susah betul aku nak faham soalan ko. benda yg ko nak tu di panggil Inter process communication (IPC), banyak teknik boleh digunakan seperti file, pipe, etc. pada pendapat aku, file la paling senang nak difahami. http://en.wikipedia.org/wiki/Inter-process_communication Report
September 8, 201015 yr comment_1047513 aku x brp paham apa yg ko nak sbnrnya. yg aku paham ada satu fail input.txt yg contain dlm fail tu ialah "26/01/10 09:20:20 MAL BIN BIN275 TSTCB U8L5 O/CR ..N UCOS Operated". pastu berdasarkan kod yg latest ko post tu fail output.txt yg keluar ialah "BIN275 TSTCB U8L5 O/CR". tp bila aku compile yg keluar hanya "CB U8L5 O/CR ..N UCOS Op". kat sini aku dah start pening.mn satu yg betul sbnrnya. yg sbnrya ko nak keluarkan "O/CR" sahaja atau "BIN275 TSTCB U8L5 O/CR". tlng jelaskan aku yerk... Report
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.