Search Results

Search found 2136 results on 86 pages for 'dominik str'.

Page 23/86 | < Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >

  • Object allocations in the cellForRowAtIndexPath method is increasing? Is dealloc not called in prese

    - by Madan Mohan
    Hi Guys, This is PresentModelViewController, when click a button i will get this "DoctorListViewController" controller from down. object allocation are not releasing in this controller specially in cellForRowAtIndexPath delegate method. UITableViewCell and two labels allocated in this is not releasing. In the previous view The allocation count of this " UITableViewCell and two labels" is increasing.Also the dealloc method in this view controller is not called when I dismiss the modelviewcontrller, that is way I have released in the close method. please suggest me a right solution Thank you. import "DoctorListViewController.h" @implementation DoctorListViewController @synthesize doctorList; - (id)init { if (self = [super init]) { self.title=@"Doctors List"; UIView *myView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; myView.autoresizingMask=YES; [myView setBackgroundColor:[UIColor groupTableViewBackgroundColor]]; myTableView=nil; myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,0,320,420) style:UITableViewStylePlain]; myTableView.delegate = self; myTableView.dataSource=self; [myTableView setSectionFooterHeight:5]; [myTableView setSectionHeaderHeight:15]; [myTableView setSeparatorColor:[UIColor greenColor]]; [myView addSubview: myTableView]; UIBarButtonItem *addButton = [[UIBarButtonItem alloc]initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(closeAction)]; self.navigationItem.leftBarButtonItem = addButton; [addButton release]; self.view = myView; [myView release]; } return self; } -(void)viewWillAppear:(BOOL)animated { DoctorsAppDelegate *appDelegate = (DoctorsAppDelegate *) [ [UIApplication sharedApplication] delegate]; [self setToPortrait:appDelegate.isPortrait]; } -(void)setToPortrait:(BOOL)isPortrait { if(isPortrait == YES) { printf("\n hai i am in setToPortrait method"); [self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait]; } } -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { DoctorsAppDelegate *appDelegate = (DoctorsAppDelegate *) [ [UIApplication sharedApplication] delegate]; if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight ) { myTableView.frame=CGRectMake(0,0,480,265); appDelegate.isPortrait=NO; } else if(interfaceOrientation == UIInterfaceOrientationPortrait) { myTableView.frame=CGRectMake(0,0,320,415); appDelegate.isPortrait=YES; } return YES; } -(void)closeAction { printf("\n hai i am in close action*****************"); [doctorList release]; [myTableView release]; myTableView=nil; printf("\n myTableView retainCount :%d",[myTableView retainCount]); [[self navigationController] dismissModalViewControllerAnimated:YES]; } pragma mark methods for dataSource and delegate (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } (NSInteger)tableView:(UITableView )tableView numberOfRowsInSection:(NSInteger)section { / int numberOfRows = [doctorList count]; if(numberOfRows =[doctorList count]){ numberOfRows++; } return numberOfRows; */ return [doctorList count]; } (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 50; } (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = (UITableViewCell *)[myTableView dequeueReusableCellWithIdentifier:@"MyIdentifier"]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"MyIdentifier"]autorelease]; UIView* elementView = [ [UIView alloc] initWithFrame:CGRectMake(5,5,300,480)]; elementView.tag = 0; [cell.contentView addSubview:elementView]; [elementView release]; } UIView* elementView = [cell.contentView viewWithTag:0]; for(UIView* subView in elementView.subviews) { [subView removeFromSuperview]; } if(indexPath.row != [doctorList count]) { cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; Doctor *obj= [doctorList objectAtIndex:indexPath.row]; UILabel *firstNameLabel =[[[UILabel alloc] initWithFrame:CGRectMake(5,2,300,15)]autorelease]; [firstNameLabel setFont:[UIFont boldSystemFontOfSize:12]]; firstNameLabel.textColor = [UIColor blackColor]; firstNameLabel.textColor =[UIColor blackColor]; firstNameLabel.numberOfLines = 0; firstNameLabel.tag=1; firstNameLabel.backgroundColor = [UIColor clearColor]; NSString *str=obj.firstName; str=[str stringByAppendingString:@" "]; str=[str stringByAppendingString:obj.lastName]; firstNameLabel.text=str; [elementView addSubview:firstNameLabel]; //[firstNameLabel release]; firstNameLabel=nil; UILabel *streetLabel =[[[UILabel alloc] initWithFrame:CGRectMake(5,20,300,15)]autorelease]; [streetLabel setFont:[UIFont systemFontOfSize:12]]; streetLabel.textColor = [UIColor blackColor]; streetLabel.numberOfLines = 0; streetLabel.tag=2; streetLabel.backgroundColor = [UIColor clearColor]; streetLabel.text=obj.streetAddress; [elementView addSubview:streetLabel]; //[streetLabel release]; streetLabel=nil; printf("\n retainCount count of firstNameLabel %d",[firstNameLabel retainCount]); printf("\n retainCount count of streetLabel %d",[streetLabel retainCount]); printf("\n retainCount count of cell %d",[cell retainCount]); } return cell; } (void )tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [myTableView deselectRowAtIndexPath:indexPath animated:YES]; DoctorDetailsViewController *doctorDetailsViewController=[[DoctorDetailsViewController alloc]init]; Doctor *obj= [doctorList objectAtIndex:indexPath.row]; BOOL isList=YES; doctorDetailsViewController.isList=isList; doctorDetailsViewController.doctorObj=obj; [[self navigationController] pushViewController:doctorDetailsViewController animated:YES]; [doctorDetailsViewController release]; } (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } (void)dealloc { printf("\n hai i am in dealloc of Doctor list view contrller"); //[doctorList release]; //[myTableView release]; [super dealloc]; } @end

    Read the article

  • What is the cause of these Visual Studio 2010 errors & warnings?

    - by volpack
    I don't know the cause of these errors I am receiving from Visual Studio 2010. This is the code from my program from line 343 to line 408: int create_den_from_img(char *img_file_name_part, int xlen, int ylen, int zlen ) { IplImage* imgs = 0; char str[80]; unsigned char *data,*imgdata; /* allocating memory */ data = (unsigned char *) malloc(xlen * ylen * zlen * sizeof(unsigned char) ); if(data==NULL) { printf("error in allocating memory \n"); exit(1); } /* Getting the filename & iterating through tiff images */ for(int k = 0; k < zlen; k++) { int count=2; int tmp=k+1; while(tmp/10) { count=count-1; tmp=tmp/10; } switch(count) { case 2:sprintf(str,"%s00%d.tif",img_file_name_part,k+1); break; case 1:sprintf(str,"%s0%d.tif",img_file_name_part,k+1); break; default:sprintf(str,"%s%d.tif",img_file_name_part,k+1); break; } printf("%s\n",str); /* Loading Image using OpenCV */ imgs=cvLoadImage(str,-1); if(imgs==NULL) { printf("error in opening image \n"); exit(1); } imgdata=(uchar *)imgs->imageData; for(int j =0; j < ylen; j++) { for(int i =0; i < xlen; i++) { data[ k*xlen*ylen + j*xlen + i ] = imgdata[ j*xlen+i ]; } } cvReleaseImage(&imgs ); } /* populating `data` variable is done. So, calling `write_den` */ if(write_den("test.den",data,xlen,ylen,zlen)==0) { printf("Error in creating den file\n"); exit(1); } printf("Den file created\n"); } These are the list of errors: Error 3 error C2143: syntax error : missing ';' before 'type' c:\examples\denfile.c 358 1 MTP_TEST Error 4 error C2143: syntax error : missing ';' before 'type' c:\examples\denfile.c 358 1 MTP_TEST Error 5 error C2143: syntax error : missing ')' before 'type' c:\examples\denfile.c 358 1 MTP_TEST Error 6 error C2143: syntax error : missing ';' before 'type' c:\examples\denfile.c 358 1 MTP_TEST Error 7 error C2065: 'k' : undeclared identifier c:\examples\denfile.c 358 1 MTP_TEST Error 9 error C2065: 'k' : undeclared identifier c:\examples\denfile.c 358 1 MTP_TEST Error 10 error C2059: syntax error : ')' c:\examples\denfile.c 358 1 MTP_TEST Error 11 error C2143: syntax error : missing ';' before '{' c:\examples\denfile.c 359 1 MTP_TEST Error 12 error C2065: 'k' : undeclared identifier c:\examples\denfile.c 361 1 MTP_TEST Error 13 error C2065: 'k' : undeclared identifier c:\examples\denfile.c 370 1 MTP_TEST Error 14 error C2065: 'k' : undeclared identifier c:\examples\denfile.c 372 1 MTP_TEST Error 15 error C2065: 'k' : undeclared identifier c:\examples\denfile.c 374 1 MTP_TEST Error 16 error C2143: syntax error : missing ';' before 'type' c:\examples\denfile.c 388 1 MTP_TEST Error 17 error C2143: syntax error : missing ';' before 'type' c:\examples\denfile.c 388 1 MTP_TEST Error 18 error C2143: syntax error : missing ')' before 'type' c:\examples\denfile.c 388 1 MTP_TEST Error 19 error C2143: syntax error : missing ';' before 'type' c:\examples\denfile.c 388 1 MTP_TEST Error 20 error C2065: 'j' : undeclared identifier c:\examples\denfile.c 388 1 MTP_TEST Error 22 error C2065: 'j' : undeclared identifier c:\examples\denfile.c 388 1 MTP_TEST Error 23 error C2059: syntax error : ')' c:\examples\denfile.c 388 1 MTP_TEST Error 24 error C2143: syntax error : missing ';' before '{' c:\examples\denfile.c 389 1 MTP_TEST Error 25 error C2143: syntax error : missing ';' before 'type' c:\examples\denfile.c 390 1 MTP_TEST Error 26 error C2143: syntax error : missing ';' before 'type' c:\examples\denfile.c 390 1 MTP_TEST Error 27 error C2143: syntax error : missing ')' before 'type' c:\examples\denfile.c 390 1 MTP_TEST Error 28 error C2143: syntax error : missing ';' before 'type' c:\examples\denfile.c 390 1 MTP_TEST Error 29 error C2065: 'i' : undeclared identifier c:\examples\denfile.c 390 1 MTP_TEST Error 31 error C2065: 'i' : undeclared identifier c:\examples\denfile.c 390 1 MTP_TEST Error 32 error C2059: syntax error : ')' c:\examples\denfile.c 390 1 MTP_TEST Error 33 error C2143: syntax error : missing ';' before '{' c:\examples\denfile.c 391 1 MTP_TEST Error 34 error C2065: 'k' : undeclared identifier c:\examples\denfile.c 392 1 MTP_TEST Error 35 error C2065: 'j' : undeclared identifier c:\examples\denfile.c 392 1 MTP_TEST Error 36 error C2065: 'i' : undeclared identifier c:\examples\denfile.c 392 1 MTP_TEST Error 37 error C2065: 'j' : undeclared identifier c:\examples\denfile.c 392 1 MTP_TEST Error 38 error C2065: 'i' : undeclared identifier c:\examples\denfile.c 392 1 MTP_TEST I've been getting these kind of errors all day long. Sometimes the code compiles, while at other time it doesn't. Its really annoying.

    Read the article

  • Python 3.1.1 Problem With Tuples

    - by Protean
    This piece of code is supposed to go through a list and preform some formatting to the items, such as removing quotations, and then saving it to another list. class process: def rchr(string_i, asciivalue): string_o = () for i in range(len(string_i)): if ord(string_i[i]) != asciivalue: string_o += string_i[i] return string_o def flist(self, list_i): cache = () cache_list = [] for line in list_i: cache = line.split('\t') cacbe[0] = process.rchr(str(cache[0]), 34) cache_list.append(cache[0]) cache_list[index] = cache index += 1 cache_list.sort() return cache_list p = process() list1a = ['cow', 'dog', '"sheep"'] list1 = p.flist(list1a) print (country_list) However; it chokes at 'string_o += string_i[i]' and gives the following error: Traceback (most recent call last): File "/Projects/Python/safafa.py", line 23, in <module> list1 = p.flist(list1a) File "/Projects/Python/safafa.py", line 14, in flist cacbe[0] = process.rchr(str(cache[0]), 34) File "/Projects/Python/safafa.py", line 7, in rchr string_o += string_i[i] TypeError: can only concatenate tuple (not "str") to tuple

    Read the article

  • The Bizarre Hidden Powers of the Preprocessor? [closed]

    - by ApprenticeHacker
    The preprocessor in C and C++ deserves an entire essay on its own to explore its rich possibilities for obfuscation. It is true that the C++ (and C) preprocessor can be used for a lot of powerful stuff. #ifdefs and #defines are often used to determine platforms, compilers and backends. Manipulating the code likewise. However, can anyone list some of the most powerful and bizarre things you can do with the preprocessor? The most sinister use of the preprocessor I've found is this: #ifndef DONE #ifdef TWICE // put stuff here to declare 3rd time around void g(char* str); #define DONE #else // TWICE #ifdef ONCE // put stuff here to declare 2nd time around void g(void* str); #define TWICE #else // ONCE // put stuff here to declare 1st time around void g(std::string str); #define ONCE #endif // ONCE #endif // TWICE #endif // DONE This declares different things based on how many times the header is included. Are there any other bizarre unknown powers of the C++ preprocessor?

    Read the article

  • How to decode numeric HTML entities in PHP

    - by Yuriy
    Hello, I'm trying to decode encoded long dash from numeric entity to string, but it seems that I can't find a function which can do this properly. The best that I found is mb_decode_numericentity(), however, for some reason it fails to decode long dash and some other special characters. $str = '–'; // <- ' & # 8211 ;' $str = mb_decode_numericentity ( $str , Array(0xFF, 0x2FFFF, 0, 0xFFFF) , 'ISO-8859-1'); This will return "?". Anyone knows how to solve this problem?

    Read the article

  • Convert C++Builder AnsiString to std::string via boost::lexical_cast

    - by David Klein
    For a school assignment I have to implement a project in C++ using Borland C++ Builder. As the VCL uses AnsiString for all GUI Components I have to convert all of my std::strings to AnsiString for the sake of displaying. std::string inp = "Hello world!"; AnsiString outp(inp.c_str()); works of course but is a bit tedious to write and code duplication I want to avoid. As we use Boost in other contexts I decided to provide some helper functions go get boost::lexical_cast to work with AnsiString. Here is my implementation so far: std::istream& operator>>(std::istream& istr, AnsiString& str) { istr.exceptions(std::ios::badbit | std::ios::failbit | std::ios::eofbit); std::string s; std::getline(istr,s); str = AnsiString(s.c_str()); return istr; } In the beginning I got Access Violation after Access Violation but since I added the .exceptions() stuff the picture gets clearer. When the conversion is performed I get the following Exception: ios_base::eofbit set [Runtime Error/std::ios_base::failure] Does anyone have an idea how to fix it and can explain why the error occurs? My C++ experience is very limited. The conversion routine the other way round would be: std::ostream& operator<<(std::ostream& ostr,const AnsiString& str) { ostr << (str.c_str()); return ostr; } Maybe someone will spot an error here too :) With best regards! Edit: At the moment I'm using the edited version of Jem, it works in the beginning. After a while of using the programm the Borland Codeguard mentions some pointer arithmetic in already freed regions. Any ideas how this could be related? The Codeguard log (I'm using the german version, translations marked with stars): ------------------------------------------ Fehler 00080. 0x104230 (r) (Thread 0x07A4): Zeigerarithmetik in freigegebenem Speicher: 0x0241A238-0x0241A258. **(pointer arithmetic in freed region)** | d:\program files\borland\bds\4.0\include\dinkumware\sstream Zeile 126: | { // not first growth, adjust pointers | _Seekhigh = _Seekhigh - _Mysb::eback() + _Ptr; |> _Mysb::setp(_Mysb::pbase() - _Mysb::eback() + _Ptr, | _Mysb::pptr() - _Mysb::eback() + _Ptr, _Ptr + _Newsize); | if (_Mystate & _Noread) Aufrufhierarchie: **(stack-trace)** 0x00411731(=FOSChampion.exe:0x01:010731) d:\program files\borland\bds\4.0\include\dinkumware\sstream#126 0x00411183(=FOSChampion.exe:0x01:010183) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#465 0x0040933D(=FOSChampion.exe:0x01:00833D) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#151 0x00405988(=FOSChampion.exe:0x01:004988) d:\program files\borland\bds\4.0\include\dinkumware\ostream#679 0x00405759(=FOSChampion.exe:0x01:004759) D:\Projekte\Schule\foschamp\src\Server\Ansistringkonverter.h#31 0x004080C9(=FOSChampion.exe:0x01:0070C9) D:\Projekte\Schule\foschamp\lib\boost_1_34_1\boost/lexical_cast.hpp#151 Objekt (0x0241A238) [Größe: 32 Byte] war erstellt mit new **(Object was created with new)** | d:\program files\borland\bds\4.0\include\dinkumware\xmemory Zeile 28: | _Ty _FARQ *_Allocate(_SIZT _Count, _Ty _FARQ *) | { // allocate storage for _Count elements of type _Ty |> return ((_Ty _FARQ *)::operator new(_Count * sizeof (_Ty))); | } | Aufrufhierarchie: **(stack-trace)** 0x0040ED90(=FOSChampion.exe:0x01:00DD90) d:\program files\borland\bds\4.0\include\dinkumware\xmemory#28 0x0040E194(=FOSChampion.exe:0x01:00D194) d:\program files\borland\bds\4.0\include\dinkumware\xmemory#143 0x004115CF(=FOSChampion.exe:0x01:0105CF) d:\program files\borland\bds\4.0\include\dinkumware\sstream#105 0x00411183(=FOSChampion.exe:0x01:010183) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#465 0x0040933D(=FOSChampion.exe:0x01:00833D) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#151 0x00405988(=FOSChampion.exe:0x01:004988) d:\program files\borland\bds\4.0\include\dinkumware\ostream#679 Objekt (0x0241A238) war Gelöscht mit delete **(Object was deleted with delete)** | d:\program files\borland\bds\4.0\include\dinkumware\xmemory Zeile 138: | void deallocate(pointer _Ptr, size_type) | { // deallocate object at _Ptr, ignore size |> ::operator delete(_Ptr); | } | Aufrufhierarchie: **(stack-trace)** 0x004044C6(=FOSChampion.exe:0x01:0034C6) d:\program files\borland\bds\4.0\include\dinkumware\xmemory#138 0x00411628(=FOSChampion.exe:0x01:010628) d:\program files\borland\bds\4.0\include\dinkumware\sstream#111 0x00411183(=FOSChampion.exe:0x01:010183) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#465 0x0040933D(=FOSChampion.exe:0x01:00833D) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#151 0x00405988(=FOSChampion.exe:0x01:004988) d:\program files\borland\bds\4.0\include\dinkumware\ostream#679 0x00405759(=FOSChampion.exe:0x01:004759) D:\Projekte\Schule\foschamp\src\Server\Ansistringkonverter.h#31 ------------------------------------------ Ansistringkonverter.h is the file with the posted operators and line 31 is: std::ostream& operator<<(std::ostream& ostr,const AnsiString& str) { ostr << (str.c_str()); **(31)** return ostr; } Thanks for your help :)

    Read the article

  • Single specific string replace method Objective C

    - by Sam
    Hi guys, I wanted to know if theres a single method or way that will help me replace strings for specific characters. like MALE - M FEMALE - F CHILD - P The longer way out is this.. [str stringByreplacingOccurencesOfString:@"MALE" withString:@"M"]; [str stringByreplacingOccurencesOfString:@"FEMALE" withString:@"F"]; [str stringByreplacingOccurencesOfString:@"CHILD" withString:@"P"]; I was wondering if theres another way in which i can reduce lines of code here, specially when there are alots of things to replace. thanks. this is for iPhone OS.

    Read the article

  • flex and bison: wrong output

    - by user2972227
    I am doing a homework using flex and bison to make a complex number calculator. But my program cannot give a correct output. .lex file: %option noyywrap %{ #include<stdio.h> #include<stdlib.h> #include "complex_cal.h" #define YYSTYPE complex #include "complex_cal.tab.h" void RmWs(char* str); %} /* Add your Flex definitions here */ /* Some definitions are already provided to you*/ ws [ \t]+ digits [0-9] number (0|[1-9]+{digits}*)\.?{digits}* im [i] complexnum {ws}*[-]*{ws}*{number}{ws}*[+|-]{ws}*{number}{ws}*{im}{ws}* op [-+*/()] %% {complexnum} {RmWs(yytext); sscanf(yytext,"%lf %lf",&(yylval.real),&(yylval.img)); return CNUMBER;} {ws} /**/ {op} return *yytext; %% /* function provided to student to remove */ /* all the whitespaces from a string. */ void RmWs(char* str){ int i=0,j=0; char temp[strlen(str)+1]; strcpy(temp,str); while (temp[i]!='\0'){ while (temp[i]==' '){i++;} str[j]=temp[i]; i++; j++; } str[j]='\0'; } .y file: %{ #include <stdio.h> #include <stdlib.h> #include "complex_cal.h" /* prototypes of the provided functions */ complex complex_add (complex, complex); complex complex_sub (complex, complex); complex complex_mul (complex, complex); complex complex_div (complex, complex); /* prototypes of the provided functions */ int yylex(void); int yyerror(const char*); %} %token CNUMBER %left '+' '-' %left '*' '/' %nonassoc '(' ')' %% /* start: Add your grammar rules and actions here */ complexexp: complexexp '+' complexexpmultidiv {$$=complex_add($1, $3);} | complexexp '-' complexexpmultidiv {$$=complex_sub($1, $3);} | complexexpmultidiv {$$.real=$1.real;$$.img=$1.img;} ; complexexpmultidiv: complexexpmultidiv '*' complexsimple {$$=complex_mul($1, $3);} | complexexpmultidiv '/' complexsimple {$$=complex_div($1, $3);} | complexsimple {$$.real=$1.real;$$.img=$1.img;} ; complexsimple: '(' complexexp ')' {$$.real=$2.real;$$.img=$2.img;} | '(' CNUMBER ')' {$$.real=$2.real;$$.img=$2.img;} ; /* end: Add your grammar rules and actions here */ %% int main(){ return yyparse(); } int yyerror(const char* s){ printf("%s\n", s); return 0; } /* function provided to do complex addition */ /* input : complex numbers c1, c2 */ /* output: nothing */ /* side effect : none */ /* return value: result of addition in c3 */ complex complex_add (complex c1, complex c2){ /* c1 + c2 */ complex c3; c3.real = c1.real + c2.real; c3.img = c1.img + c2.img; return c3; } /* function provided to do complex subtraction */ /* input : complex numbers c1, c2 */ /* output: nothing */ /* side effect : none */ /* return value: result of subtraction in c3 */ complex complex_sub (complex c1, complex c2){ /* c1 - c2 */ complex c3; c3.real = c1.real - c2.real; c3.img = c1.img - c2.img; return c3; } /* function provided to do complex multiplication */ /* input : complex numbers c1, c2 */ /* output: nothing */ /* side effect : none */ /* return value: result of multiplication in c3 */ complex complex_mul (complex c1, complex c2){ /* c1 * c2 */ complex c3; c3.real = c1.real*c2.real - c1.img*c2.img; c3.img = c1.img*c2.real + c1.real*c2.img; return c3; } /* function provided to do complex division */ /* input : complex numbers c1, c2 */ /* output: nothing */ /* side effect : none */ /* return value: result of c1/c2 in c3 */ complex complex_div (complex c1, complex c2){ /* c1 / c2 (i.e. c1 divided by c2 ) */ complex c3; double d; /*divisor calculation using the conjugate of c2*/ d = c2.real*c2.real + c2.img*c2.img; c3.real = (c1.real*c2.real + c1.img*c2.img)/d; c3.img = (c1.img*c2.real - c1.real*c2.img)/d; return c3; } .h file: #include <string.h> /* struct for holding a complex number */ typedef struct { double real; double img; } complex; /* define the return type of FLEX */ #define YYSTYPE complex Script for compiling the file: bison -d -v complex_cal.y flex -ocomplex_cal.lex.yy.c complex_cal.lex gcc -o complex_cal complex_cal.lex.yy.c complex_cal.tab.c ./complex_cal Some correct sample run of the program: input:(5+6i)*(6+1i) output:24.000000+41.000000i input:(7+8i)/(-3-4i)*(5+7i) output:-11.720000-14.040000i input:(7+8i)/((-3-4i)*(5+7i)) output:-0.128108+0.211351i But when I run this program, the program only give an output which is identical to my input. For example, when I input (5+6i)(6+1i), it just gives (5+6i)(6+1i). Even if I input any other things, for example, input "abc" it just gives "abc" and is not syntax error. I don't know where the problem is and I hope to know how to solve it.

    Read the article

  • python __getattr__ help

    - by Stefanos Tux Zacharakis
    Reading a Book, i came across this code... # module person.py class Person: def __init__(self, name, job=None, pay=0): self.name = name self.job = job self.pay = pay def lastName(self): return self.name.split()[-1] def giveRaise(self, percent): self.pay = int(self.pay *(1 + percent)) def __str__(self): return "[Person: %s, %s]" % (self.name,self.pay) class Manager(): def __init__(self, name, pay): self.person = Person(name, "mgr", pay) def giveRaise(self, percent, bonus=.10): self.person.giveRaise(percent + bonus) def __getattr__(self, attr): return getattr(self.person, attr) def __str__(self): return str(self.person) It does what I want it to do, but i do not understand the __getattr__ function in the Manager class. I know that it Delegates all other attributes from Person class. but I do not understand the way it works. for example why from Person class? as I do not explicitly tell it to. person(module is different than Person(class) Any help is highly appreciated :)

    Read the article

  • How to print non-ASCII characters in Python

    - by Roman
    I have a problem when I'm printing (or writing to a file) the non-ASCII characters in Python. I've resolved it by overriding the str method in my own objects, and making "x.encode('utf-8')" inside it, where x is a property inside the object. But, if I receive a third-party object, and I make "str(object)", and this object has a non-ASCII character inside, it will fail. So the question is: is there any way to tell the str method that the object has an UTF-8 codification, generically? I'm working with Python 2.5.4.

    Read the article

  • VIrtual class problem

    - by ugur
    What i think about virtual class is, if a derived class has a public base, let's say, class base, then a pointer to derived can be assigned to a variable of type pointer to base without use of any explicit type conversion. But what if, we are inside of base class then how can we call derived class's functions. I will give an example: class Graph{ public: Graph(string); virtual bool addEdge(string,string); } class Direct:public Graph{ public: Direct(string); bool addEdge(string,string); } Direct::Direct(string filename):Graph(filename){}; When i call constructor of Direct class then it calls Graph. Now lets think Graph function calls addedge. Graph(string str){ addedge(str,str); } When it calls addedge, even if the function is virtual, it calls Graph::edge. What i want is, to call Direct::addedge. How can it be done?

    Read the article

  • Virtual class problem

    - by ugur
    What i think about virtual class is, if a derived class has a public base, let's say, class base, then a pointer to derived can be assigned to a variable of type pointer to base without use of any explicit type conversion. But what if, we are inside of base class then how can we call derived class's functions. I will give an example: class Graph{ public: Graph(string); virtual bool addEdge(string,string); } class Direct:public Graph{ public: Direct(string); bool addEdge(string,string); } Direct::Direct(string filename):Graph(filename){}; When i call constructor of Direct class then it calls Graph. Now lets think Graph function calls addedge. Graph(string str){ addedge(str,str); } When it calls addedge, even if the function is virtual, it calls Graph::edge. What i want is, to call Direct::addedge. How can it be done?

    Read the article

  • Trying to create link with NSTextField

    - by Chris
    I'm using this category (is that right?) http://www.nightproductions.net/references/dsclickableurltextfield_reference.html#setAttributedStringValue to implement clickable textfields. I've imported the header file in my controller class and set it's attributed string value like this NSAttributedString* str = [[NSAttributedString alloc] initWithString:@"http://www.yahoo.com"]; [url setAttributedStringValue:(NSAttributedString *)str]; [str release]; The text field is not selectable and not editable. The text field value is set but it's not clickable and it's not a link. Thanks in advance.

    Read the article

  • Data tweaking code runs fine when executed directly - but never stops when used in trigger

    - by MBaas
    I have written some code to ensure that items on an order are all numbered (the "position number" or "item number" has been introduced only recently and we did not want to go and change all related code - as it is "asthetics only" and has no functional impact.) So, the idea is to go and check for an records that jave an itemno of NULL or 0 - and then compute one and assign it. When executing this code in a query window, it works fine. When putting it into an AFTER INSERT-trigger, it loops forever. So what is wrong here? /****** Objekt: Trigger [SetzePosNr] Skriptdatum: 02/28/2010 20:06:29 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TRIGGER [SetzePosNr] ON [dbo].[bestellpos] AFTER INSERT AS BEGIN DECLARE @idb int DECLARE @idp int DECLARE @pnr int SELECT @idp=id,@idb=id_bestellungen FROM bestellpos WHERE posnr IS NULL OR posnr=0 WHILE @idp IS NOT NULL BEGIN SELECT @pnr = 1+max(posnr) FROM bestellpos WHERE id_bestellungen = @idb print( 'idp=' + str(@idp) + ', idb=' + str(@idb) + ', posnr=' + str(@pnr)) UPDATE bestellpos SET posnr=@pnr WHERE id=@idp SELECT @idp=id,@idb=id_bestellungen FROM bestellpos WHERE posnr IS NULL OR posnr=0 END END

    Read the article

  • Trying to understand strtok

    - by Karthick
    Consider the following snippet that uses strtok to split the string madddy. char* str = (char*) malloc(sizeof("Madddy")); strcpy(str,"Madddy"); char* tmp = strtok(str,"d"); std::cout<<tmp; do { std::cout<<tmp; tmp=strtok(NULL, "dddy"); }while(tmp!=NULL); It works fine, the output is Ma. But by modifying the strtok to the following, tmp=strtok(NULL, "ay"); The output becomes Madd. So how does strtok exactly work? I have this question because I expected strtok to take each and every character that is in the delimiter string to be taken as a delimiter. But in certain cases it is doing that way but in few cases, it is giving unexpected results. Could anyone help me understand this?

    Read the article

  • How to pass email from one form to another page's form with javascript

    - by zac
    I am trying to have an email signup form on one page populate the email block on another page by passing it through the url and pulling it out with document.write. The first form is something like: <form action="/sign-up"> <input type="text" name="passEmail"><input type="submit"></form> And the recieving form is like : <form name="theForm"> <input type='text' name='email'></form> And I am trying a script like this <SCRIPT LANGUAGE="javascript"> var locate = window.location document.theForm.email.value = locate var text = document.theForm.email.value function delineate(str) { theEmail = str.indexOf("=") + 1; return(str.substring(theEmail)); } document.write(delineate(text)); </SCRIPT> Instead of pulling the email after the = in the url it is pulling the entire url. Can someone help me accomplish this?

    Read the article

  • File is not Writing using FileOutputStream in java

    - by Krishna
    I have Java Desktop Swing application in which i am trying to write xml file but its not writing data into file here my code is FileOutputStream fileOutputStream = new FileOutputStream(input_file); SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection(); SOAPMessage soapResponse = soapConnection.call(soapcall, url); String str = WebServiceDAO.soapMessageToString(soapResponse); System.err.println("String*****" + str); fileOutputStream.write(str.getBytes()); fileOutputStream.close(); here i am getting data but its not writing in file what could be the prob?

    Read the article

  • WebService: Firefox can't establish a connection to the server at 192.168.10.203:8080

    - by hp1
    Hi, I am trying to create a WebService. I am not able to access the URL. If I try to connect to http://192.168.10.203:8080/EchoBeanService/EchoBean?wsdl I get an error: Firefox can't establish a connection to the server at 192.168.10.203:8080 However, if I am able to connect to the using localhost in the URL: http://localhost:8080/EchoBeanService/EchoBean?wsdl Echo.java package services; public interface Echo { public String printEcho(); public String printEchoParam(String str); } EchoBean.java package model; import javax.jws.WebService; import javax.ejb.Stateless; import javax.jws.WebMethod; import services.Echo; @Stateless @WebService public class EchoBean implements Echo { public EchoBean(){} @WebMethod public String printEcho(){ return "WebServices Echo "; } @WebMethod public String printEchoParam(String str){ return ("In PrintEcho( String " + str +" )" ); } } -H

    Read the article

  • Win32 api call via C# fails!

    - by user434186
    Hi. I have a C++ function exported as api like this: #define WIN322_API __declspec(dllexport) WIN322_API char* Test(LPSTR str); WIN322_API char* Test(LPSTR str) { return "hello"; } the function is exported as API correctly by the .DEF file, cause i can see it in Dependency Walker tool. Now i have a C# tester program: [DllImport("c:\\win322.dll")] public static extern string Test([MarshalAs(UnmanagedType.LPStr)] String str); private void Form1_Load(object sender, EventArgs e) { string _str = "0221"; Test(_str); // runtime error here! } on calling the Test() method i get the error: "A call to PInvoke function 'MyClient!MyClient.Form1::Test' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature." i tried many other data types and marshalings, but got nothing! plz help me!

    Read the article

  • Replace text in string with delimeters using Regex

    - by user1057735
    I have a string something like, string str = "(50%silicon +20%!(20%Gold + 80%Silver)| + 30%Alumnium)"; I need a Regular Expression which would Replace the contents in between ! and | with an empty string. The result should be (50%silicon +20% + 30%Alumnium). If the string contains something like (with nested delimiters): string str = "(50%silicon +20%!(80%Gold + 80%Silver + 20%!(20%Iron + 80%Silver)|)| + 30%Alumnium)"; The result should be (50%silicon +20% + 30%Alumnium) - ignoring the nested delimiters. I've tried the following Regex, but it doesn't ignore the nesting: Regex.Replace(str , @"!.+?\|", "", RegexOptions.IgnoreCase);

    Read the article

  • preg_replace hell

    - by Jason
    I'm trying to use preg_replace to get some data from a remote page, but I'm having a bit of an issue when it comes to sorting out the pattern. function getData($Url){ $str = file_get_contents($Url); if(strlen($str)>0){ preg_match("/\<span class=\"SectionHeader\"\>title\</span>/<br/>/\<div class=\"header2\"\>(.*)\</div\></span\>/",$str,$title); return $title[1]; } } Here's the HTML as is before I ended up throwing a million slashes at it (looks like I forgot a part or two): <span class="cell CellFullWidth"><span class="SectionHeader">mytitle</span><br/><div class="Center">Event Name</div></span> Where Event Name is the data I want to return in my function. Thanks a lot guys, this is a pain in the ass.

    Read the article

  • The document.body.innerHTML.replace() replaces the url in the address bar.

    - by divya
    I am trying to make an extension as part of which i want certain words in the web pages to be highlighted. The document.body.innerHTML.replace() replaces the url in the address bar as well. So the moment this code gets exwecuted the page doesnt get loaded properly.. Is there a way around this problem? onPageLoad: function(aEvent) { var doc = aEvent.originalTarget; var str="the"; var regex; var regex = new RegExp(str, "g"); doc.body.innerHTML = doc.body.innerHTML.replace(regex,'<b>'+str+'</b>'); } The listener is registered as follows in a browser.xul overlay: window.addEventListener("load", function() { myExtension.init(); }, false); var myExtension = { init: function() { var appcontent = document.getElementById("appcontent"); // browser if(appcontent) appcontent.addEventListener("DOMContentLoaded", myExtension.onPageLoad, false); },

    Read the article

  • ValueError: too many values to unpack in a tuple

    - by falosi
    Please put some light on why am getting a too many to unpack (ValueError in my for loop).Have tried deb naislist = [('CONTROL FILE', '0', '0', '0'), ('REDO LOG', '0', '0', '0'), ('ARCHIVED LOG', '.69', '.59', '3'), ('BACKUP PIECE', '46.54', '0', '192'), ('IMAGE COPY', '0', '0', '0'), ('FLASHBACK LOG', '10.15', '6.31', '82'), ('FOREIGN ARCHIVED LOG', '0', '0', '0')] print "size of naislist is ",len((naislist)) heading = ('MAIN MENU', 'LEVELS', 'LEVEL2', 'LEVEL3') rearrange = dict(zip((0, 1, 2, 3), (len(str(x)) for x in heading))) for tu, x in naislist: rearrange.update((i, max(rearrange[i], len(str(el)))) for i, el in enumerate(tu)) rearrange[4] = max(rearrange[4], len(str(x))) forkit = '|'. join('%%-%ss' % rearrange[i] for i in xrange(0, 4)) print '\n'.join((forkit % heading, '-|-'.join(rearrange[i] * '-' for i in xrange(4)), '\n'.join(forkit % (a, b, c, d) for (a, b, c), d in naislist)))

    Read the article

  • Having a base class function depend on its child class C#

    - by Junk Junk
    I have a Base class with a method that a child class will almost always override. However, instead of replacing the base class' method entirely, I would like for whatever is derived in the child class to be added to what is already in the base class. For Example: class BaseClass public string str() { var string = "Hello my name is" ; } class ChildClass : BaseClass public override string str(){ var string = "Sam"; } The point is that if I want to access the str() method by creating an instance of the ChildClass, the string will print out as "Hello, my name is Sam". I've been looking around and all I have been finding is that this should NOT happen, as the base class shouldn't even know that it is being inherited. So, if the design is false, how would I go about doing this? Keep in mind that there will be multiple child classes inheriting from BaseClass. Thank you

    Read the article

  • JSDoc adding real code in documentation

    - by Marco Demaio
    Do you know if there is a some sort of <code> tag in JSDoc? I need to add pieces of code in mt documentation like this: /** * This function does something see example below: * <p> * var x = foo("test"); //it will show "test" message * * @param {string} str: string argumnet that will be shown in message */ function foo(str) { alert(str); } I need that the code in the comments being displaied by JSDoc as code (if not sintax highlighetd, at least as code like in preformatted or something with grey background) Thanks.

    Read the article

< Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >