homework

Read and write struct in C

I have a struct: typedef struct student { char fname[30]; char sname[30]; char tname[30]; Faculty fac; int course; char group[10]; int room; int bad; } Student; I read it from the file: Database * dbOpen(char *fname) { FILE *fp = fopen(fname, "rb"); List ...

Android: How to get product info after barcode scanning?

Alright, so I'm trying to write a program for Android for a project for school, I figured out how to use Intents to scan, but once I find a product, how do I get that info into my app? For example, say I'm getting info from upcdatabase.com, I would just add the barcode number to the end of the url, but then how to I draw that data in? Th...

NullPointerException and the best way to deal with it

Note: This is homework/assignment feel not to answer if you don't want to. Ok after some search and reading these: http://stackoverflow.com/questions/425439/how-to-check-if-array-element-is-null-to-avoid-nullpointerexception-in-java http://stackoverflow.com/questions/963936/gracefully-avoiding-nullpointerexception-in-java http://c2.com...

How can I calculate an optimal UDP packet size for a datastream?

Short radio link with a data source attached with a needed throughput of 1280 Kbps over IPv6 with a UDP Stop-and-wait protocol, no other clients or noticeable noise sources in the area. How on earth can I calculate what the best packet size is to minimise overhead? UPDATE I thought it would be an idea to show my working so far: IPv6 ha...

What is wrong with the below statement(C#3.0 / Lambda)

what is wrong in the below Enumerable.Range(0, objEntityCode.Count - 1).Select(i => { options.Attributes[i] = new EntityCodeKey { EntityCode = objEntityCode[i].EntityCodes , OrganizationCode = Constants.ORGANIZATION_CODE }; }) .ToArray(); Throwing error The type arguments for method 'System.Linq.Enumerable.Select(System.Collec...

How to Retrieve Method's Signature in Squeak

printThisMethodSig: aSomething stack := thisContext stackOfSize: 2. Transcript show: (stack at: 2); cr. stack at: 2 returns the method context of the current method. It is possible to retrieve the compiled method of the current method using method message. I want to be able to print the whole signature of the method, for example: from:...

How do I shear an image in MATLAB without using built-in functions?

I want a method to shear an image without using the built-in functions (methods) of MATLAB. How can I do this? ...

Unable to free const pointers in C

How can I free a const char*? I allocated new memory using malloc, and when I'm trying to free it I always receive the error "incompatible pointer type" The code that causes this is something like: char* name="Arnold"; const char* str=(const char*)malloc(strlen(name)+1); free(str); // error here ...

C++ string array from ifstream

I have a program that I need to read in an array of strings from a file. The array must be C type strings (char * or char[]). Using the following code, I get a bad access error: for (i = 0; i < MAX_WORDS && !inputFile.eof(); i++) { inputFile >> words[i]; } words is declared as: char *words[MAX_WORDS]; ...

Subset Problem -- Any Materials?

Yes this is a homework/lab assignment. I am interesting in coming up with/finding an algorithm (I can comprehend :P) for using "backtracking" to solve the subset sum problem. Anyone have some helpful resources? I've spent the last hour or so Googling with not much like finding something I think I could actually use. xD Thanks SO! ...

Using Threads to Handle Sockets

I am working on a java program that is essentially a chat room. This is an assignment for class so no code please, I am just having some issues determining the most feasible way to handle what I need to do. I have a server program already setup for a single client using threads to get the data input stream and a thread to handle sending ...

How to save a whole project in python

Hello I have developed a small game in python using ZODB as backend for DB processing.I have never done game programming before.I was hoping if someone can tell me as to how I can save my current game and then reload it using python.The database filename is data.fs and there are three more ZODB files in my folder.One being for locks rest...

binary operator "<"

Consider this expression as a "selection" control structure on integer "x": 0 < x < 10, with the intention that the structure returns TRUE if "x" is in the range 1..9. Explain why a compiler should not accept this expression. (In particular, what are the issues regarding the binary operator "<"? Explain how a prefix operator could be ...

In what ways can a flag be used within the program design?

In what ways can a flag be used within the program design? How can you use multiple flags? ...

Infinite loop when adding a row to a list in a class in python3

I have a script which contains two classes. (I'm obviously deleting a lot of stuff that I don't believe is relevant to the error I'm dealing with.) The eventual task is to create a decision tree, as I mentioned in this question. Unfortunately, I'm getting an infinite loop, and I'm having difficulty identifying why. I've identified ...

How to generate a random number

I have to create a test for homework using Selenium IDE and create a scenario to generate a random number. I'm stuggling with what I need to type and what field to type in. What should I type in?: Command Target Value Thanks ...

Help with Java Program for Prime numbers

Hello everyone, I was wondering if you can help me with this program. I have been struggling with it for hours and have just trashed my code because the TA doesn't like how I executed it. I am completely hopeless and if anyone can help me out step by step, I would greatly appreciate it. Problem In this project you will write a Java pro...

How to iterate through a tree in spiral order ???

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 the output in spiral order should be 1 3 2 4 5 6 7 15 14 13 12 11 10 9 8 ...

Swapping values using pointers

I have this code fragment int i = 5; int k = 7; int * iPtr; int * jPtr; int * kPtr; iPtr = &i; kPtr = &k; I am required to swap i and k using the pointers. This is how I'm doing it: *jPtr = *kPtr ; *kPtr = *iPtr ; *iPtr = *jPtr ; Is this the best way to do it, or is there a better way? ...

Read file and print in specific format. C++

I have to write a program in C++ and I haven't used this laugauge before. I know how to write it in Java or C#, but I should write it in C++! The code should read a text file (I do this step) and then print the output in a specific format using the array (I don't now how to do this step) For example: The file has the following: Task ...