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;
...
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!
...
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()
{
...
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...
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(){
...
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...
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...
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. ...
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
...
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...
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 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!
...
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...
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...
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.
...
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();
}
...
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...
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?
...
how to reverse the input number and get the output
...
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...