homework

Error using scanf() for user input

I am getting a weird problem while using scanf() to store data into a union. Here's my code #include <stdio.h> union Student { float score; char grade; }; int main(void) { union Student jack; printf("Enter student score : "); scanf("%f", &jack.score); printf("Score : %f", jack.score); jack.score=0; ...

php: Parse string from html

I have opend a html file with file_get_contents('http://www.example.com/file.html') and want to parse the line "ParseThis": <h1 class=\"header\">ParseThis<\/h1> As you can see the it's within a h1 tag (the first h1 tag from the html file). How can I get the Text "ParseThis" ? Thanks! ...

Have I managed the memory correctly here? (simple C++ stack)

I'm a complete noob with dynamically allocated memory. Will this have a memory leak or any other memory problem? #include <iostream.h> template <class T> class stack { struct node { T value; node* next; }; public: stack() { ...

Reviewing C++: Int to Char

Hello all, It's been a while since I have worked with C++, I'm currently catching up for an upcoming programming test. I have the following function that has this signature: void MyIntToChar(int *arrayOfInt,char* output) Int is an array of integers and char* output is a buffer that should be long enough to hold the string represent...

[java] Anything wrong about my Intset Class?

I design new IntSet Class that use ArrayList. first, i extends Intset by ArrayList and i start implement method. i face some problem in my union() method. here is my code... public class IntSet extends ArrayList<Integer>{ private static final long serialVersionUID = 1L; private ArrayList<Integer> intset; public IntSet(){ ...

Simple Pseudocode Code Question

I'm a little new to pseudocode. I understand what the code is saying, but having a hard time putting the pieces together. How should I be thinking to understand what this code is doing: Suppose that a1, a2, . . . , ak is an array of k numbers. What does the following code fragment do? Briefly explain why. Assume that all the indented li...

Linear Search Algorithm Optimization

I just finished a homework problem for Computer Science 1 (yes, it's homework, but hear me out!). Now, the assignment is 100% complete and working, so I don't need help on it. My question involves the efficiency of an algorithm I'm using (we aren't graded on algorithmic efficiency yet, I'm just really curious). The function I'm about to...

Extremely Simple Regex Expression Clarification (10)*

Hey all, I feel bad about asking a question so simple, but I can't figure this out for the life of me. I need to construct a NFA based on some languages, and the only one I can't figure out is this one: L = (10)* Note that I am not asking for any help concerning the FSM, but only some clarification on what the language represents. ...

What other standards are for Database Connection?

I'm doing a research for a homework, but I don't seem to find any other standard way to connect to a database, so far I've found this two: ole db odbc I've also found jdbc, but that's java only, as ado.net or pdo. I would like some help or advice links or books would be greatly appreciared. :D ...

How does it work, Test *pObj = new Test(); as constructor does not return anything

Hi, I am trying to get better at c++. I have a Test class and below code in main(). Test *pObj = new Test(); If we debug by steping one by one instruction, First it goes to new function to allocate memory, then it calls constructor. Then it comes back to main() function. As we all know, constructor does not return anything. In that ca...

is it necessary to overload placement new operator, when we overload new operator ?

Hi, I have below piece of code class Test { public: Test(){} Test(int i) {} void* operator new (size_t size) { void *p = malloc(size); return p; } //void* operator new (size_t size, Test *p) //{ // return p; //} }; int main() { Test *p = new Test; int i = 10; new(p) Test(i); } Above p...

[VHDL] Simulation not working - port mapping wrong?

VHDL code First of all, sorry for the redirect, but it's easier that way. I'm building a digital clock, but as you can see, clock_AN and clock_seg_out do not change. Is this caused by a wrong port mapping? Thanks! ...

Why string string is allowed and int int is not allowed by Compiler?

Hi, I am just trying to check whether compiler allows type name as variable name. When i tried int int; It reported an error saying error C2632: 'int' followed by 'int' is illegal But when i tried #include <string> using namespace std; int main() { string string; } It didn't give any error. Both string and int are...

Questions on my homework in a C# class

I am taking a programming class in C# and here is my first assignment, and already I am in need of help. I think I can handle the problem I just need help getting started. Create an Average class with a public data member to collect the sum of the integer entries and a public data member to hold the double average of the sum of the 1...

How to find an average grade for each student with SQL

Hi, I have a list of grades that students received. Each student appears multiple times in the table. How do I produce a list of all the students with their average grade? P.s. I've tried looking at previously asked questions to see if I can find something relevant, but with no luck. ...

Error checking so that I don't divide by 10 everytime

How can I check to see if the textbox is empty and then only divide by that number of int. As you can see now I will divide by 10 everytime so now I need help with error checking. namespace Assignment1_White { public partial class Form1 : Form { public Form1() { InitializeComponent(); } ...

How to implement multi-threading and problem specific questions in vba

I have a spreadsheet with about 25 sheets. In some of the sheets specifically 6,7,13,17,18,19 I'm populating them with Database values. In some sheets I'm populating two table's data. Now I need to create a button which will do the following operation. On the button click event I need to traverse through all sheets and see if any sheet i...

Trouble calculating with CRC (computer math)

Hi So I have a CRC polynomial x3 + x1 + 1 on a letter 'P' I need to divide the binary code of 'P' by the polynomial But I'm stuck at this point.. 0 1 0 1 0 0 0 0 000 | 1 0 1 1 1 0 1 1 | --------- | 1 1 1 0 0 ? 1 0 1 1 I don't understand what to do with the 1 in front? Does someone know an answer here? ...

palindrome or reverse in c

how to reverse the input number and get the output ...

C Pointer Question

I am really getting confused on how pointers work. I am trying to write short little programs that will illuminate exactly how they work and I am having some troubles. For example: char c[3]; //Creates an array of 3 bytes - the first 2 bytes can be used for characters and the 3rd would need to be used for the terminating zero *c = 'a...