Posts

java - Strange issue with an array -

so i'm in middle of working on class called planner [no main in it's separate class], i'm having issue declaring array eclipse. need enter in eclipse see because have no idea means 'syntax error on token ";", , expected'. here code: import java.util.scanner; public class planner { private int maxevents = 1000; private int numevents = 0; private int choice; int[] anarray; anarray = new int [1000]; public void planner() { scanner scan = new scanner (system.in); system.out.print("press 1 add event. 2 display events day. 3 display events week. 4 quit: "); choice = scan.nextint(); if (choice == 1){addevent();} if (choice == 2){displayonedate();} if (choice == 3){displayoneweek();} if (choice == 4){system.out.println("have day.");} else {planner();} } public void addevent() { event newevent = new event(); if (numevents == maxevents){system.out.println("error: no more room.");}...

C Pointers Past Paper -

i'm looking @ past paper course i'm doing @ university, , there question c pointers. i reckon have reasonable grasp of how work, question confusing me: consider running c program fragment: int x[4] = {0,2,4,6}; int *y; y = &x[2]; *(x + 2) = y[1] + 1; value of expression *y afterwards? (a) 2 (b) 4 (c) 5 (d) 7 (e) 8 now, in answers said question, says answer d . i'm super confused, seeing as: the value of x not declared, i'd have thought impossible evaluate x+2 y isn't array, how can y[1] evaluated? why 7 correct answer here? lets break down: int x[4] = {0,2,4,6}; x [0] = 0 x [1] = 2 x [2] = 4 x [3] = 6 int *y; pointer integer y point location in x x [0] = 0 // <-- y ? x [1] = 2 // <-- y ? x [2] = 4 // <-- y ? x [3] = 6 // <-- y ? y = &x[2]; have specified y points x[2] x [0] = 0 x [1] = 2 x [2] = 4 // <-- y (or y[0]) x [3] = 6 *(x + 2) same x[2] so: x[2] = y[1] + 1...

asp.net mvc - Razor - How do I output the current cshtml filename -

for debugging purposes, output html comment indicating filename of current cshtml file @ beginning , end of every cshtml file. for example, i'd when view source of generated webpage, see this: <!-- begin _layout.cshtml --> ... headings , such ... <!-- begin about.cshtml --> ... generated content about.cshtml ... <!-- end about.cshtml --> ... footers , such ... <!-- end _layout.cshtml --> i'm new platform, i'm not sure right terminology this, let alone in api look. i'm hoping @ least can edit of cshtml files , reference object @ runtime contains filename property, in syntax similar to: <!-- begin @object.optionalproperty.optionalsubproperty.filename --> or, alternatively, way modify rendering engine automatically @ beginning , end of every rendered file. thank time , responses.

c unix execl not working with string built with strcat -

i trying run execl pathname built command line arguments. not working hardcoded strings being concatenated still did not work. if supply char *path = "some path name" , pass execl, works correctly. #include <stdio.h> int main(int argc,char *argv[]){ //set char path name char pathname[256]; strcat(pathname,"/bin/"); strcat(pathname,"ls"); //"ls" replaced arg[1] int pid=fork(); if (pid==0){ execl(pathname,"ls",(char *)0); } else{ wait((int*)0); } return 0; } i've printed out pathname make sure "/bin/ls" is. the problem here: char pathname[256]; strcat(pathname,"/bin/"); you did not initialize pathname . therefore, contents "indeterminate" , call strcat has officially known undefined behavior -- allowed literally anything . concrete thing happened was, there binary garbage in memory space allocated pathname , , strcat cheerfully treated string, contents of...

cocoa - Coreplot Legend drawing outside of plot frame -

Image
i have chart os x app can resized window. expected when width reduced enough legend truncated or clipped. however, spilling outside of plot area shown below. ideally, legend truncate or @ least clip contents. how can done? my legend setup follows - (void)configurelegend { // 1 - graph instance cptgraph *graph = self.graphhostingview.hostedgraph; // 2 - create legend cptlegend *thelegend; if (!thelegend) { thelegend = [cptlegend legendwithgraph:graph]; } //configure text cptmutabletextstyle *textstyle = [cptmutabletextstyle textstyle]; textstyle.color = [cptcolor colorwithcomponentred:0.612f green:0.612f blue:0.612f alpha:1.00f]; textstyle.fontname = @"helveticaneue"; textstyle.fontsize = 12.0f; thelegend.textstyle = textstyle; // 3 - configure legend thelegend.numberofcolumns = 1; thelegend.fill = nil; thelegend.borderlinestyle = nil; thelegend.swatchsize = cgsizemake(10.0, 10.0); thel...

java - Using Default Locale Separator with NumberFormat, and then rounding number -

i have java code: numberformat nf = numberformat.getnumberinstance(locale.getdefault()); decimalformat df = (decimalformat)nf; newcurr = df.format(dcurr); basically, pass in number, 12.344. i want rounded 2 places , use locale's default separator (either "." or ","). so, example in countries in europe, want 12,34 so far code above, halfway there. 12,344. can't find place decimalformat of ("#.##") can rounded. in other words, can incorporate decimalformat df=new decimalformat("#.##"); in above? or have find way? edit: thinking have old way of (100.00 * var)/ 100.00 , pass in? the method setmaximumfractiondigit work. see rest of available methods: http://docs.oracle.com/javase/7/docs/api/java/text/decimalformat.html#setmaximumfractiondigits%28int%29

asp.net mvc - Custom validation of HttpPostedFileBase -

i use mvc5. i've got issue file uploading using httppostedfilebase. i've got form can can choose file disk , type information it(in textbox). when submit form controller action called. in action open file , check if has specific data(related data textbox). validation here. can't using jquery - it's complex. server side validation option. if validation fails return model(with file) view after i've got validation error next file field file field empty. i've read that's hard return file view. don't want use ajax upload file. want simple. if got article can help, please share me. how can solve problem? i know mentioned not using ajax file upload, think solution simple one. using following jquery plugin ( https://blueimp.github.io/jquery-file-upload/ ), can automate process , if there validation issues in file, can return following model error. string errors = "errors returned complex logic"; if (!string.isnullorempty(errors)) { ...