Search Results

Search found 1552 results on 63 pages for 'homework'.

Page 14/63 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Calculate car filled up times

    - by Ivan
    Here is the question: The driving distance between Perth and Adelaide is 1996 miles. On the average, the fuel consumption of a 2.0 litre 4 cylinder car is 8 litres per 100 kilometres. The fuel tank capacity of such a car is 60 litres. Design and implement a JAVA program that prompts for the fuel consumption and fuel tank capacity of the aforementioned car. The program then displays the minimum number of times the car’s fuel tank has to be filled up to drive from Perth to Adelaide. Note that 62 miles is equal to 100 kilometres. What data will you use to test that your algorithm works correctly? Here is what I've done so far: import java.util.Scanner;// public class Ex4{ public static void main( String args[] ){ Scanner input = new Scanner( System.in ); double distance, consumption, capacity, time; distance = Math.sqrt(1996/62*100); consumption = Math.sqrt(8/100); capacity = 60; time = Math.sqrt(distance*consumption/capacity); System.out.println("The car's fuel tank need to be filled up:" + time + "times"); } } I can compile it but the problem is that the result is always 0.0, can anyone help me what's wrong with it ?

    Read the article

  • Using Tkinter in python to edit the title bar

    - by Dan
    I am trying to add a custom title to a window but I am having troubles with it. I know my code isn't right but when I run it, it creates 2 windows instead, one with just the title tk and another bigger window with "Simple Prog". How do I make it so that the tk window has the title "Simple Prog" instead of having a new additional window. I dont think I'm suppose to have the Tk() part because when i have that in my complete code, there's an error from tkinter import Tk, Button, Frame, Entry, END class ABC(Frame): def __init__(self,parent=None): Frame.__init__(self,parent) self.parent = parent self.pack() ABC.make_widgets(self) def make_widgets(self): self.root = Tk() self.root.title("Simple Prog")

    Read the article

  • RMI-applets - Cannot understand error message

    - by aeter
    In a simple RMI game I'm writing (an assignment in uni), I reveice: java.rmi.MarshalException: error marshalling arguments; nested exception is: java.net.SocketException: Broken pipe at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:138) at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178) at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132) at $Proxy2.drawWorld(Unknown Source) at PlayerServerImpl$1.actionPerformed(PlayerServerImpl.java:180) at javax.swing.Timer.fireActionPerformed(Timer.java:271) at javax.swing.Timer$DoPostEvent.run(Timer.java:201) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) The error message appears after the second Player is registered with the RMI Server and the server starts to send the image (the array of pixels) to the 2 applets. The PlayerImpl and the PlayerServerImpl both extend UnicastRemoteObject. I have been struggling with other error messages for some time now, but I cannot understand how to troubleshoot this one. Please help. The relevant parts of the code are: PlayerServerImpl.java: ... timer = new Timer(10, new ActionListener() { // every 10 milliseconds do: @Override public void actionPerformed(ActionEvent e) { ... BufferedImage buff_image = new BufferedImage(GAME_APPLET_WIDTH, GAME_APPLET_HEIGHT, BufferedImage.TYPE_INT_RGB); // create a graphics context on the buffered image Graphics buff_g = buff_image.createGraphics(); ... // draw the score somewhere on the screen buff_g.drawString(score, GAME_APPLET_WIDTH - 20, 10); ... int[] rgbs = new int[GAME_APPLET_WIDTH * GAME_APPLET_HEIGHT]; int imgPixelsGrabbed[] = buff_image.getRGB(0,0,GAME_APPLET_WIDTH,GAME_APPLET_HEIGHT,rgbs,0,GAME_APPLET_WIDTH); // send the new state to the applets for (Player player : players) { player.drawWorld(imgPixelsGrabbed); System.out.println("Sent image to player"); } PlayerImpl.java: private PlayerApplet applet; public PlayerImpl(PlayerApplet applet) throws RemoteException { super(); this.applet = applet; } ... @Override public void drawWorld(int[] imgPixelsGrabbed) throws RemoteException { applet.setWorld(imgPixelsGrabbed); applet.repaint(); } ... PlayerApplet.java: ... private int[] world; // an array of pixels for the new image to be drawn ... // register players player = new PlayerImpl(applet); String serverIPAddressPort = ipAddressField.getText(); if (validateIPAddressPort(serverIPAddressPort)) { server = (PlayerServer) Naming.lookup("rmi://" + serverIPAddressPort + "/PlayerServer"); server.register(player); idPlayer = server.sendPlayerID(); ... @Override public void update(Graphics g) { buff_img = createImage((ImageProducer) new MemoryImageSource(getWidth(), getHeight(), world, 0, getWidth())); Graphics gr = buff_img.getGraphics(); paint(gr); g.drawImage(buff_img, 0, 0, this); } public void setWorld(int[] world) { this.world = world; }

    Read the article

  • weighted matching algorithm in Perl

    - by srk
    Problem : We have equal number of men and women.each men has a preference score toward each woman. So do the woman for each man. each of the men and women have certain interests. Based on the interest we calculate the preference scores. So initially we have an input in a file having x columns. First column is the person(men/woman) id. id are nothing but 0.. n numbers.(first half are men and next half woman) the remaining x-1 columns will have the interests. these are integers too. now using this n by x-1 matrix... we have come up with a n by n/2 matrix. the new matrix has all men and woman as their rows and scores for opposite sex in columns. We have to sort the scores in descending order, also we need to know the id of person related to the scores after sorting. So here i wanted to use hash table. once we get the scores we need to make up pairs.. for which we need to follow some rules. My trouble is with the second matrix of n by n/2 that needs to give information of which man/woman has how much preference on a woman/man. I need these scores sorted so that i know who is the first preferred woman/man, 2nd preferred and so on for a man/woman. I hope to get good suggestions on the data structures i use.. I prefer php or perl. Thank you in advance

    Read the article

  • Scheme. Tail recursive ?

    - by n00b
    Hi guys, any tail-recursive version for the below mentioned pseudocode ? Thanks ! (define (min list) (cond ((null? list '()) ((null? (cdr list)) (car list)) (#t (let ((a (car list)) (b (min (cdr list))) ) (if (< b a) b a) ) ) ) )

    Read the article

  • How to use XPath to filter elements by TextContent? get parent by axis?

    - by Michael Mao
    Hi all: I've found a similar question on SO, however, that seems not exactly what I wanna achieve: Say, this is a sample XML file: <root> <item> <id isInStock="true">10001</id> <category>Loose Balloon</category> </item> <item> <id isInStock="true">10001</id> <category>Bouquet Balloon</category> </item> <item> <id isInStock="true">10001</id> <category>Loose Balloon</category> </item> </root> If I wanna get a "filtered" subset of the item elements from this XML, how could I use an XPath expression to directly address that? XPathExpression expr = xpath.compile("/root/item/category/text()"); I now know this would evaluate to be the collection of all the TextContent from the categories, however, that means I have to use a collection to store the values, then iterate, then go back to grab other related info such as the item id again. Another question is : how could I refer to the parent node properly? Say, this xpath expression would get me the collection of all the id nodes, right? But what I want is the collection of item nodes: XPathExpression expr = xpath.compile("/root/item/id[@isInStock='true']"); I know I should use the "parent" axis to refer to that, but I just cannot make it right... Is there a better way of doing this sort of thing? Learning the w3cschools tutorials now... Sorry I am new to XPath in Java, and thanks a lot in advance.

    Read the article

  • Decimal Base Conversion using PYTHON

    - by Butinyane More
    PROBLEM DESCRIPTION Given a decimal number, and a new base to represent it in. If the base is larger than 10, use capital letters for the digits(that is, A is 10, B is 11 and so forth). The decimal number given, and the new base, will both be integer values, separated by a space. The base to convert to will always be smaller than or equal to 30. Please create a program that will convert a decimal number to any base in this instance. When evaluating the program the sample input must something like: 18 2 and the program must output the following: 10010 Please i beg of you to send me a solution to this problem as soon as possible.

    Read the article

  • Having problem with C++ file handling

    - by caramel1991
    Our lecturer has given us a task,I've attempted it and try every single effort I can,but I still struggle with one of the problem in it,here goes the question: The company you work at receives a monthly report in a text format. The report contains the following information. • Department Name • Head of Department Name • Month • Minimum spending of the month • Maximum spending of the month Your program is to obtain the name of the input file from the user. Implement a structure to represent the data: Once the file has been read into your program, print out the following statistics for the user: • List which department has the minimum spending per month by month • List which department has the minimum spending by month by month Write the information into a file called “MaxMin.txt” Then do a processing so that the Department Name, Head of Department Name, Minimum spending and Maximum spending are written to separate files based on the month, eg Jan, Feb, March and so on. and of course our lecturer does send us a text file with the content: Engineering Bill Jan 2000 15000 IT Jack Jan 300 20000 HR Jill Jan 1500 10000 Engineering Bill Feb 5000 45000 IT Jack Feb 4500 7000 HR Jill Feb 5600 60000 Engineering Bill Mar 5000 45000 IT Jack Mar 4500 7000 HR Jill Mar 5600 60000 Engineering Bill Apr 5000 45000 IT Jack Apr 4500 7000 HR Jill Apr 5600 60000 Engineering Bill May 2000 15000 IT Jack May 300 20000 HR Jill May 1500 10000 Engineering Bill Jun 2000 15000 IT Jack Jun 300 20000 HR Jill Jun 1500 10000 and here's the c++ code I've written ue#include include include using namespace std; struct Record { string depName; string head; string month; float max; float min; string name; }myRecord[19]; int main () { string line; ofstream minmax,jan,feb,mar,apr,may,jun; char a[50]; char b[50]; int i = 0,j,k; float temp; //float maxjan=myRecord[0].max,maxfeb=myRecord[0].max,maxmar=myRecord[0].max,maxapr=myRecord[0].max,maxmay=myRecord[0].max,maxjune=myRecord[0].max; float minjan=myRecord[1].min,minfeb=myRecord[1].min,minmar=myRecord[1].min,minapr=myRecord[1].min,minmay=myRecord[1].min,minjune=myRecord[1].min; float maxjan=0,maxfeb=0,maxmar=0,maxapr=0,maxmay=0,maxjune=0; //float minjan=0,minfeb=0,minmar=0,minapr=0,minmay=0,minjune=0; string maxjanDep,maxfebDep,maxmarDep,maxaprDep,maxmayDep,maxjunDep; string minjanDep,minfebDep,minmarDep,minaprDep,minmayDep,minjunDep; cout<<"Enter file name: "; cina; ifstream myfile (a); //minmax.open ("MaxMin.txt"); if (myfile.is_open()){ while (! myfile.eof()){ myfilemyRecord[i].depNamemyRecord[i].headmyRecord[i].monthmyRecord[i].minmyRecord[i].max; cout << myRecord[i].depName<<"\t"< cout<<"Enter file name: "; cinb; ifstream myfile1 (b); minmax.open ("MaxMin.txt"); jan.open ("Jan.txt"); feb.open ("Feb.txt"); mar.open ("March.txt"); apr.open ("April.txt"); may.open ("May.txt"); jun.open ("Jun.txt"); if (myfile1.is_open()){ while (! myfile1.eof()){ myfile1myRecord[i].depNamemyRecord[i].headmyRecord[i].monthmyRecord[i].minmyRecord[i].max; if (myRecord[i].month == "Jan"){ jan<< myRecord[i].depName<<"\t"< if (maxjan< myRecord[i].max){ maxjan=myRecord[i].max; maxjanDep=myRecord[i].depName;} //if (minjan myRecord[i].min){ // minjan=myRecord[i].min; //minjanDep=myRecord[i].depName; //} for (k=1;k<=3;k++){ for (j=0;j<2;j++){ if (myRecord[j].minmyRecord[j+1].min){ temp=myRecord[j].min; myRecord[j].min=myRecord[j+1].min; myRecord[j+1].min=temp; minjanDep=myRecord[j].depName; }}} } if (myRecord[i].month == "Feb"){ feb<< myRecord[i].depName<<"\t"< //if (minfebmyRecord[i].min){ //minfeb=myRecord[i].min; //minfebDep=myRecord[i].depName; //} for (k=1;k<=3;k++){ for (j=0;j<2;j++){ if (myRecord[j].minmyRecord[j+1].min){ temp=myRecord[j].min; myRecord[j].min=myRecord[j+1].min; myRecord[j+1].min=temp; minfebDep=myRecord[j+1].depName; }}} } if (myRecord[i].month == "Mar"){ mar<< myRecord[i].depName<<"\t"< if (myRecord[i].month == "Apr"){ apr<< myRecord[i].depName<<"\t"< if (minaprmyRecord[i].min){ minapr=myRecord[i].min; minaprDep=myRecord[i].min;} } if (myRecord[i].month == "May"){ may< if (minmaymyRecord[i].min){ minmay=myRecord[i].min; minmayDep=myRecord[i].depName;} } if (myRecord[i].month == "Jun"){ jun<< myRecord[i].depName<<"\t"< if (minjunemyRecord[i].min){ minjune=myRecord[i].min; minjunDep=myRecord[i].depName;} } i++; myfile.close(); } minmax<<"department that has maximum spending at jan "< else{ cout << "Unable to open file"< } sorry inside that code ue#include should has iostream along with another two #include fstream and string,but at here it was treated as html tag,so i can't type it. my problem here is,I can't seems to get the minimum spending,I've try all I can but I'm still lingering on it,any idea??THANK YOU!

    Read the article

  • Exam Questions that use .Demand or .LinkDemand COULD NOT BE ANY MORE CONFUSING OR AMBIGIOUS ????

    - by IbrarMumtaz
    I am 110% sure this is WRONG !!!! Q.12) You develop a library, and want to ensure that the functions in the library cannot be either directly or indirectly invoked by applications that are not running on the local intranet. What attribute would you add to each method? A. [UrlIdentityPermission(SecurityAction.RequestRefuse, Url="http://myintranet")] B. [UrlIdentityPermission(SecurityAction.LinkDemand, Url="http://myintranet")] (correct answer) C. [UrlIdentityPermission(SecurityAction.Demand, Url="http://myintranet")] D. [UrlIdentityPermission(SecurityAction.Assert, Url="http://myintranet")] Explanation Link-Demand should be used as it ensures that all callers in the call stack have the necessary permission. In this case it ensures that all callers in the call stack are on the local intranet. There is an indentical question on Transencer so I already had a clue what was goin but Transcender was much more informative that this drivel as it mentioned class level and not assembly level. It also mentioned that some callers maybe coming externally from the company intranet via authroised and authenticated credentials. With information is easy to see why .Demand on would be wong option to go for? So Transcender was right .... so I thgt fine, that makes sense. With think information still fresh in my brain I had a good idea was was going on in the question. To my surprise .Demand was wrong agin !!!! WHAT? I am really starting to hate this setting now? I cannot be any more p*ssed right now!!! :@ Thanks For Reading, Ibrar

    Read the article

  • Designing bayesian networks

    - by devoured elysium
    I have a basic question about Bayesian networks. Let's assume we have an engine, that with 1/3 probability can stop working. I'll call this variable ENGINE. If it stops working, then your car doesn't work. If the engine is working, then your car will work 99% of the time. I'll call this one CAR. Now, if your car is old(OLD), instead of not working 1/3 of the time, your engine will stop working 1/2 of the time. I'm being asked to first design the network and then assign all the conditional probabilities associated with the table. I'd say the diagram of this network would be something like OLD -> ENGINE -> CAR Now, for the conditional probabilities tables I did the following: OLD |ENGINE ------------ True | 0.50 False | 0.33 and ENGINE|CAR ------------ True | 0.99 False | 0.00 Now, I am having trouble about how to define the probabilities of OLD. In my point of view, old is not something that has a CAUSE relationship with ENGINE, I'd say it is more a characteristic of it. Maybe there is a different way to express this in the diagram? If the diagram is indeed correct, how would I go to make the tables? Thanks

    Read the article

  • URI encode and HTML ecnode

    - by Anil Namde
    If i have the xml/html data to post we need to encode the data to avoid the XSS validation. So should we use HTMLencode or URI encoding for this. If URI encoding is used will it cause issues as form POST automatically URI encode all the data before sending.

    Read the article

  • Maddening Linked List problem

    - by Mike
    This has been plaguing me for weeks. It's something really simple, I know it. Every time I print a singly linked list, it prints an address at the end of the list. #include <iostream> using namespace std; struct node { int info; node *link; }; node *before(node *head); node *after(node *head); void middle(node *head, node *ptr); void reversep(node *head, node *ptr); node *head, *ptr, *newnode; int main() { head = NULL; ptr = NULL; newnode = new node; head = newnode; for(int c1=1;c1<11;c1++) { newnode->info = c1; ptr = newnode; newnode = new node; ptr->link = newnode; ptr = ptr->link; } ptr->link=NULL; head = before(head); head = after(head); middle(head, ptr); //reversep(head, ptr); ptr = head; cout<<ptr->info<<endl; while(ptr->link!=NULL) { ptr=ptr->link; cout<<ptr->info<<endl; } system("Pause"); return 0; } node *before(node *head) { node *befnode; befnode = new node; cout<<"What should go before the list?"<<endl; cin>>befnode->info; befnode->link = head; head = befnode; return head; } node *after(node *head) { node *afnode, *ptr2; afnode = new node; ptr2 = head; cout<<"What should go after the list?"<<endl; cin>>afnode->info; ptr2 = afnode; afnode->link=NULL; ptr2 = head; return ptr2; } void middle(node *head, node *ptr) { int c1 = 0, c2 = 0; node *temp, *midnode; ptr = head; while(ptr->link->link!=NULL) { ptr=ptr->link; c1++; } c1/=2; c1-=1; ptr = head; while(c2<c1) { ptr=ptr->link; c2++; } midnode = new node; cout<<"What should go in the middle of the list?"<<endl; cin>>midnode->info; cout<<endl; temp=ptr->link; ptr->link=midnode; midnode->link=temp; } void reversep(node *head, node *ptr) { node *last, *ptr2; ptr=head; ptr2=head; while(ptr->link!=NULL) ptr = ptr->link; last = ptr; cout<<last->info; while(ptr!=head) { while(ptr2->link!=ptr) ptr2=ptr2->link; ptr = ptr2; cout<<ptr->info; } } I'll admit that this is class work, but even the professor can't figure it out, and says that its probably something insignificant that we're overlooking, but I can't put my mind to rest until I find out what it is.

    Read the article

  • ANSI C blackjack assignment, linux GCC compiler, i'm stuck...

    - by Bill Adams
    Here's what i have so far... I have yet to figure out how i'm going to handle the 11 / 1 situation with an ace, and when the player chooses an option for hit/stand, i get segfault. HELP!!! #include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #define DECKSIZE 52 #define VALUE 9 #define FACE 4 #define HANDSIZE 26 typedef struct { int value; char* suit; char* name; }Card; typedef struct { int value; char* suit; char* name; }dealerHand; typedef struct { int value; char* suit; char* name; }playerHand; Card cards[DECKSIZE]; dealerHand deal[HANDSIZE]; playerHand dealt[HANDSIZE]; char *faceName[]={"two","three", "four","five","six", "seven","eight","nine", "ten", "jack","queen", "king","ace"}; char *suitName[]={"spades","diamonds","clubs","hearts"}; void printDeck(){ int i; for(i=0;i<DECKSIZE;i++){ printf("%s of %s value = %d\n ",cards[i].name,cards[i].suit,cards[i].value); if((i+1)%13==0 && i!=0) printf("-------------------\n\n"); } } void shuffleDeck(){ srand(time(NULL)); int this; int that; Card temp; int c; for(c=0;c<10000;c++){ //c is the index for number of individual card shuffles should be set to c<10000 or more this=rand()%DECKSIZE; that=rand()%DECKSIZE; temp=cards[this]; cards[this]=cards[that]; cards[that]=temp; } } /*void hitStand(i,y){ // I dumped this because of a segfault i couldn't figure out. int k; printf(" Press 1 to HIT or press 2 to STAND:"); scanf("%d",k); if(k=1){ dealt[y].suit=cards[i].suit; dealt[y].name=cards[i].name; dealt[y].value=cards[i].value; y++; i++; } } */ int main(){ int suitCount=0; int faceCount=0; int i; int x; int y; int d; int p; int k; for(i=0;i<DECKSIZE;i++){ //this for statement builds the deck if(faceCount<9){ cards[i].value=faceCount+2; }else{ //assigns face cards as value 10 cards[i].value=10; } cards[i].suit=suitName[suitCount]; cards[i].name=faceName[faceCount++]; if(faceCount==13){ //this if loop increments suit count once cards[i].value=11; //all faces have been assigned, and also suitCount++; //assigns the ace as 11 faceCount=0; } //end building deck } /*printDeck(); //prints the deck in order shuffleDeck(); //shuffles the deck printDeck(); //prints the deck as shuffled This was used in testing, commented out to keep the deck hidden!*/ shuffleDeck(); x=0; y=0; for(i=0;i<4;i++){ //this for loop deals the first 4 cards, dealt[y].suit=cards[i].suit; //first card to player, second to dealer, dealt[y].name=cards[i].name; //as per standard dealing practice. dealt[y].value=cards[i].value; i++; y++; deal[x].suit=cards[i].suit; deal[x].name=cards[i].name; deal[x].value=cards[i].value; x++; } printf(" Dealer's hand is: %s of %s and XXXX of XXXX. (Second card is hidden!)\n",deal[0].name,deal[0].suit,deal[1].name,deal[1].suit); printf(" Player's hand is: %s of %s and %s of %s.\n",dealt[0].name,dealt[0].suit,dealt[1].name,dealt[1].suit); printf(" the current value of the index i=%d\n",i); //this line gave me the value of i for testing d=deal[0].value+deal[1].value; p=dealt[0].value+dealt[1].value; if(d==21){ printf(" The Dealer has Blackjack! House win!\n"); }else{ if(d>21){ printf(" The dealer is Bust! You win!\n"); }else{ if(d>17){ printf(" Press 1 to HIT or 2 to STAND"); scanf("%d",k); if(k==1){ dealt[y].suit=cards[i].suit; dealt[y].name=cards[i].name; dealt[y].value=cards[i].value; y++; i++; } }else{ if(d<17){ printf(" Dealer Hits!"); deal[x].suit=cards[i].suit; deal[x].name=cards[i].name; deal[x].value=cards[i].value; x++; i++; } } } } return 0; }

    Read the article

  • finding shortest valid path in a colored-edge graphs

    - by user1067083
    Given a directed graph G, with edges colored either green or purple, and a vertex S in G, I must find an algorithm that finds the shortest path from s to each vertex in G so the path includes at most two purple edges (and green as much as needed). I thought of BFS on G after removing all the purple edges, and for every vertex that the shortest path is still infinity, do something to try to find it, but I'm kinda stuck, and it takes alot of the running time as well... Any other suggestions? Thanks in advance

    Read the article

  • Generalizing Fibonacci sequeue with SICStus Prolog

    - by Christophe Herreman
    I'm trying to find a solution for a query on a generalized Fibonacci sequence (GFS). The query is: are there any GFS that have 885 as their 12th number? The initial 2 numbers may be restricted between 1 and 10. I already found the solution to find the Nth number in a sequence that starts at (1, 1) in which I explicitly define the initial numbers. Here is what I have for this: fib(1, 1). fib(2, 1). fib(N, X) :- N #> 1, Nmin1 #= N - 1, Nmin2 #= N - 2, fib(Nmin1, Xmin1), fib(Nmin2, Xmin2), X #= Xmin1 + Xmin2. For the query mentioned I thought the following would do the trick, in which I reuse the fib method without defining the initial numbers explicitly since this now needs to be done dynamically: fib2 :- X1 in 1..10, X2 in 1..10, fib(1, X1), fib(2, X2), fib(12, 885). ... but this does not seem to work. Is it not possible this way to define the initial numbers, or am I doing something terribly wrong? I'm not asking for the solution, but any advice that could help me solve this would be greatly appreciated.

    Read the article

  • C SIGSEGV Handler & Mprotect

    - by pws5068
    I'm constructing a program which uses mprotect() to restrict a block of memory from accessing. When the memory is requested, a SIGSEGV is thrown which I listen for using a signal() call. Once the SIGSEGV has been detected, I need to somehow access the pointer to the memory that was requested (that threw the fault) and the size of the segment requested. Is this possible? void fifoSigHandler(){ // Needs to only remove protection from requested block of virtual memory mprotect(fifoVm,(size_t)fifoVm_size,PROT_WRITE); printf("Caught Seg Fault"); } void fifo_init(void* vm, int vm_size, int n_frames, int page_size) { fifoVm = vm; fifoVm_size = vm_size; fifoFrames = n_frames; fifoPageSize = page_size; mprotect(fifoVm,(size_t)fifoVm_size,PROT_NONE); signal(SIGSEGV, fifoSigHandler); } Additionally, is there a way to determine the level of mprotect() a block of memory is currently assigned (PROT_NONE,PROT_READ, etc..)?

    Read the article

  • creating child process

    - by rishabh
    Write a program to creates two childs by using send –pipe and receive –pipe primitives.Each child Process reads from a different serial line and sends the character read back to parent process through a pie. The parent process outputs all characters received. A child terminates when exclamation point character is received.The parent process terminates after both children have terminate.

    Read the article

  • SELECT SQL statement problem when getting info from an accdb in VB.Net

    - by Shane Fagan
    Hi again all, im getting the error below for this SQL statement in VB.Net SQLString = "SELECT AllPropertyDetails.PropertyID, Street, Town, County, Acres, Quotas, ResidenceDetails, Status, HighestBid, AskingPrice FROM AllPropertyDetails " SQLString += "INNER JOIN Land ON AllPropertyDetails.PropertyID = Land.PropertyID " SQLString += "WHERE Deleted = False " If PriceRadioButton.Checked = True Then SQLString += "ORDER BY AskingPrice ASC" ElseIf AcresRadioButton.Checked = True Then SQLString += "ORDER BY Acres ASC" End If Any ideas why its not working? The fields in the DB and the table names seem ok but its not working :/ System.InvalidOperationException was unhandled Message="An error occurred creating the form. See Exception.InnerException for details. The error is: No value given for one or more required parameters." Source="AuctioneerProject" StackTrace: at AuctioneerProject.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190 at AuctioneerProject.My.MyProject.MyForms.get_LandReport() at AuctioneerProject.ReportsMenu.LandButton_Click(Object sender, EventArgs e) in C:\Users\admin\Desktop\Auctioneers\AuctioneerProject\AuctioneerProject\ReportsMenu.vb:line 4 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(ApplicationContext context) at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) at AuctioneerProject.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: System.Data.OleDb.OleDbException ErrorCode=-2147217904 Message="No value given for one or more required parameters." Source="Microsoft Office Access Database Engine" StackTrace: at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.OleDb.OleDbCommand.ExecuteReader() at AuctioneerProject.LandReport.load_Land() in C:\Users\admin\Desktop\Auctioneers\AuctioneerProject\AuctioneerProject\LandReport.vb:line 37 at AuctioneerProject.LandReport.PriceRadioButton_CheckedChanged(Object sender, EventArgs e) in C:\Users\admin\Desktop\Auctioneers\AuctioneerProject\AuctioneerProject\LandReport.vb:line 79 at System.Windows.Forms.RadioButton.OnCheckedChanged(EventArgs e) at System.Windows.Forms.RadioButton.set_Checked(Boolean value) at AuctioneerProject.LandReport.InitializeComponent() in C:\Users\admin\Desktop\Auctioneers\AuctioneerProject\AuctioneerProject\LandReport.designer.vb:line 40 at AuctioneerProject.LandReport..ctor() in C:\Users\admin\Desktop\Auctioneers\AuctioneerProject\AuctioneerProject\LandReport.vb:line 5 InnerException:

    Read the article

  • string replace in file using C

    - by Hristo
    I haven't yet implemented this, I'm still in the thinking stage, but I have to go through a file and replace a certain string with another string. For example, <img src="/images/logo.gif" ... should become <img src="/proxy/www.example.com/images/logo.gif" ... Any advice on how I can approach this? Perhaps there exist some "string replace" C functions that would do this for me that I don't know about...? Right now, if I had to write this function myself, I would give it as parameters the file, string to replace, replacement string. Then I would manually go through the file and look for an occurrence of the string and recreate it. This, however, seems very inefficient. Are there better ways to do this? Thanks, Hristo

    Read the article

  • Cracking the Playfair cipher

    - by wwrob
    I have the ciphertext and an encrypting program (with the key hardcoded in). How would I go about finding the key? Surely the availability of the encryptor must open up possibilities beyond brute-forcing it.

    Read the article

  • How to exploit Diffie-hellman to perform a man in the middle attack

    - by jfisk
    Im doing a project where Alice and Bob send each other messages using the Diffie-Hellman key-exchange. What is throwing me for a loop is how to incorporate the certificate they are using in this so i can obtain their secret messages. From what I understand about MIM attakcs, the MIM acts as an imposter as seen on this diagram: Below are the details for my project. I understand that they both have g and p agreed upon before communicating, but how would I be able to implement this with they both having a certificate to verify their signatures? Alice prepares ?signA(NA, Bob), pkA, certA? where signA is the digital signature algorithm used by Alice, “Bob” is Bob’s name, pkA is the public-key of Alice which equals gx mod p encoded according to X.509 for a fixed g, p as specified in the Diffie-Hellman key- exchange and certA is the certificate of Alice that contains Alice’s public-key that verifies the signature; Finally, NA is a nonce (random string) that is 8 bytes long. Bob checks Alice's signature, and response with ?signB{NA,NB,Alice},pkB,certB?. Alice gets the message she checks her nonce NA and calculates the joint key based on pkA, pkB according to the Diffie-Hellman key exchange. Then Alice submits the message ?signA{NA,NB,Bob},EK(MA),certA? to Bob and Bobrespondswith?SignB{NA,NB,Alice},EK(MB),certB?. where MA and MB are their corresponding secret messages.

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >