Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

Input from file in C, data types -


thanks in advance taking time read through question...

/* binary search use gen_window.comp */ #include <stdio.h>  int main() {   char line[1000];   double sig, e;    file *fp, *fopen();   fp = fopen("sig_data", "r");    if (fp==null){         printf("error opening file!");   }   else {         printf("processing file...");   }      while( (fgets(line, 25, fp) != null) ){         fscanf(fp, "%lf\t%lf", &e, &sig);         printf("\nthe energy is: %lf ev\nthe corresponding cross section is: %lf barns\n",e, sig);   }  } 

numbers in file of format x.xxxxxx+x or x.xxxxxx-x accordingly. c have way specify input? bother there no 'e'. cannot find documentation tells inputing exponential, returning exponential...

i not need print exact format, other exponential format fine.

i realize there should specifiers , precision in %lf, or maybe should %e, have tried makes sense me, leaving blank.

thanks help.

jester , plinth's answers broadly correct, flawed. there indeed no way make stock number-parsing routines (*scanf, atof, strtod) process number in format have. however, suggested workarounds bad. first off, personal opinion *scanf , ato* should never used, due horrifically bad handling of malformed input. more seriously, decimal-to-float conversion requires extended-precision arithmetic avoid loss of accuracy. strtod (which routine should used problem) can relied on correctly, processing mantissa , exponent separately , combining them in obvious fashion not. need intermediate type bigger double , need powers of 10 accurately computed way last bit, pow doesn't reliably give you.

so recommendation rewrite each line on fly make acceptable strtod.

  1. read each line pair of string buffers, splitting @ \t. hand, can probably away using fscanf long use %s formats. make sure each buffer has @ least 2 bytes of space available.
  2. scan each buffer + or -. use memmove shift , subsequent bytes of string down one. poke e buffer @ original position of sign. (if step 1 hand can combine step loop step.)
  3. you have number in format strtod can process.

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -