linuxuser 0 Report post Posted June 11, 2004 (edited) Problem: Write C/C++ code to parse a given sentence ( which is called String in C/C++ world ) "Test1:Test2:Test3" by character semicolon ':'. Solution should be: First String: Test1 Second String: Test2 Third String:Test3 Code: #include<stdio.h> #include<stdlib.h> #include<string.h> void parse( char* buffer, char ch ) { char firstString[100], secondString[100]; int address1,address2, strlen; char* pdest,*predest; pdest = strchr( buffer, ch ); if( pdest != NULL ){ address1 = (int)buffer; address2 = (int)pdest; strlen = address2 - address1; if( strlen <= 0 ) { printf("Oooopps fuked up."); return;} strncpy( firstString, buffer,strlen ); firstString[ strlen ] = 0; printf("First String:%s\n", firstString ); pdest++; predest = strchr( pdest,ch); if( predest != NULL){ address1 = (int)pdest; address2 = (int)predest; strlen = address2 - address1; if( strlen <= 0 ) { printf("Ooooops fuked up."); return;} strncpy( secondString, pdest,strlen ); secondString[ strlen ] = 0; printf("Second String:%s\n", secondString ); //Extract the last string now predest++; printf("Third String:%s\n", predest ); } } } void main( void ) { parse("Test1:Test2:Test3",':'); } Edited June 11, 2004 by rs_1915 Quote Share this post Link to post Share on other sites
Bohara 0 Report post Posted July 21, 2004 QUOTE (rs_1915 @ Jun 11 2004, 04:01 PM) Problem: Write C/C++ code to parse a given sentence ( which is called String in C/C++ world ) "Test1:Test2:Test3" by character semicolon ':'. Its so intresting RS g .. . . Quote Share this post Link to post Share on other sites
Bohara 0 Report post Posted July 21, 2004 (edited) I'm so glad to see RS g here. . . anyway C is one of the most important software to devlop to hardware. So RS g i've made one simple program about using one diode where i've used max 10v with 2-0e+00 time constant in graphic mode. U can find here the specially current with fordward bios. So anyone u can make RC/RLC circuit to using C in graphic mode. #include <stdio.h> #include <stdlib.h> #include <float.h> #include <graphics.h> #include <math.h> #include <conio.h> #define PI 3.14159 typedef char string[bUFSIZ]; void Diode_response(); void Diode_grapic(); void makegraph(); void box_draw(); float ID[500]; int main(void) { char ch; Diode_response(); printf("\n \n Do u want to open in Graphic mode[yes:y]? or no[no=n)?"); ch=getch(); if(ch=='y') { Diode_grapic(); } ch=getch(); if(ch=='n') return(0); } void Diode_response() { int i; float k,VD; k=11600.; for(i=1;i<300;i++) { VD=(float)i/500.; ID=(exp(k*(VD)/(27.+273.)))-1; } } void Diode_grapic() { int g_driver, g_mode,i; int P_time,P_data,x_pixsel,Y_axis,Max_point,P_data_1; float Y_max,X_max,Vc,X_point,Vr1,Vc1; Max_point=500; //ÃÖ´ë pixel point detectgraph(&g_driver, &g_mode); initgraph(&g_driver, &g_mode, "..\\..\\bgi"); cleardevice(); box_draw(); outtextxy(200,10,"DIODE Timeconstant response"); // Vr, Vc bata current measuring for (i=1;i<300;i++) { setcolor(14); if(ID/10000.>240.) break; line(i+50,300-(int)(ID/10000.),i+51,300-(int)(ID[i+1]/10000.)); } // Ãà ½ºÄÉÀÏ °è»ê Y_max=10; //y max value //yÃà ½ºÄÉÀÏ for(i=0;i<6;i++) { gotoxy(3,4+i*3); printf("%2.1f",Y_max-(Y_max/5)*i); } //xÃà ½ºÄÉÀÏ X_max=2; for(i=0;i<12;i+=2) { X_point=i*X_max/10; gotoxy(6+i*6,20); printf("%1.1e",X_point); } getch(); closegraph(); } void box_draw() { int i; //x ÃàÀ¸·Î ¼± ±ß±â setcolor(8); for(i=50;i<550;i+=10) { line(i,50,i,300); } setcolor(7); for(i=50;i<550;i+=50) { line(i,50,i,300); } // y ÃàÀ¸·Î ¼± ±ß±â setcolor(8); for(i=50;i<300;i+=5) { line(50,i,550,i); } setcolor(7); for(i=50;i<300;i+=50) { line(50,i,550,i); } // »ç°¢Çü ±×¸®±â setcolor(10); rectangle(50,50,550,300); } //(When u check this program, u've to change in graphic mode ur c complier) Edited July 21, 2004 by Bohara Quote Share this post Link to post Share on other sites
linuxuser 0 Report post Posted November 4, 2004 Bohara,,i didnot even see ur post until today..wow ( after so many months),,i will definitely need to check out ur code,,and i will change the graphic mode of my computer before i try it. thanks..post some more and give info on any electronic projects u r working on. Quote Share this post Link to post Share on other sites
Triene 0 Report post Posted February 15, 2005 Khai ke ke...someone give me tele lesson please. : ) Quote Share this post Link to post Share on other sites
Andriuxa 0 Report post Posted February 20, 2005 Hi guys, help me a little...I've got a program and i don't lnow how to make it. The program is: Enter a sequence of numbers (it can be negative(with -)) which end will be marked 0.Print the amount of numbers,which begins with same numbers.For example: 2334,3453,121,6456 the answer will be 3. Thanx a lot. Andrew Quote Share this post Link to post Share on other sites
Andriuxa 0 Report post Posted February 20, 2005 (edited) Hi guys, help me a little...I've got a program and i don't lnow how to make it. The program is: Enter a sequence of numbers (it can be negative(with -)) which end will be marked 0.Print the amount of numbers,which begins and ends with same number.For example: 2334,3453,121,-6456 the answer will be 3. Thanx a lot. Andrew I've made a mistake there...sorry. Edited February 20, 2005 by Andriuxa Quote Share this post Link to post Share on other sites
linuxuser 0 Report post Posted February 21, 2005 help me a little...I've got a program and i don't lnow how to make it. The program is: Enter a sequence of numbers (it can be negative(with -)) which end will be marked 0.Print the amount of numbers,which begins and ends with same number.For example: 2334,3453,121,-6456 the answer will be 3. Andriuxa, i have some psuedocode for u,,see if u can write code from there, if not i will help u. //Global variable totalNumofSameNumber = 0 do { firstNumber = 0 lastNumber = 0 while ( entry is not 0 ){ Enter a number determine this is the first number or not,, if it is remember the number firstNumber = this number determine this is the last number or not, if it is last number, compare lastNumber = this number if( firstNumber == lastNumber ) totalNumofSameNumber++; } Write next sequence of numbers. Y or N? while ( write next sequence == Y ) } Quote Share this post Link to post Share on other sites
Andriuxa 0 Report post Posted February 21, 2005 hm...interesting but I don't understand Friends told me to do this program using procedure (string and massive),but I don't know how to work with string :/ I've read about it,but... I am 1 course student...it is a little bit difficult for the first time to understand everything at one time...and a lot of task to do...need more time :/ Tell me how to write or write it if you can,please. Thanks. Quote Share this post Link to post Share on other sites
alpa 0 Report post Posted March 7, 2007 Hi, You have a very cool Forum here…loved the content. I have a question.. - “Seeking experienced programmer with following skills: strong browser UI background, specifically in JavaScript, AJAX, CSS, HTML. Also must have good system & software design skills, e.g. OOP. C++/C knowledge a plus” I came across this site called Myndnet.com where u get paid if u answer this question. It’s a platform for people to buy and sell Technology related information. Good money for people like us in the IT domain. Here the link http://www.myndnet.com/login.jsp?referral=...amp;channel=A63 Sign up is free…check it out… You can contact me at my id here for more questions : barot.alpa@gmail.com Cheers Alpa Quote Share this post Link to post Share on other sites