C :: Is NodePtr Store Address Of Structure
Feb 1, 2015
I'm reading through a data structure textbook. I'm doing the part of Linked list. here's the code from the textbook:I'm not clear with pointer.what I'm confused is that the code created a pointer to the structure (*NodePtr)
Q1. Is NodePtr store the address of the structure??
Q2. Are top, np, last address of the structure??
Q3. here.....NodePtr makeNode(int);... does it returns an address of the structure which is np?? but following part np is used as a pointer??
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct node{
int num;
struct node* next;
}Node, *NodePtr;
}
[code]....
View 4 Replies
ADVERTISEMENT
Oct 27, 2014
I'm using the SDL library and trying to match the C++11 standards... Anyway, I thought about a vector where I store all the addresses of game instances, so I can access them anytime... I tried with this function:
int instance_new(std::vector<uintptr_t> &instance_id, unsigned &instance_size, Instance *pointer) {
instance_id[instance_size] = reinterpret_cast<std::uintptr_t>(pointer);
instance_size++;
instance_id.resize(instance_size);
return 0;
}
Where "Instance" is the 'parent' class of various child classes like the player. So, if I have to search the existing of a thing in my game, I should check if the address references to an instance of class. How can I do this?
View 1 Replies
View Related
Apr 11, 2014
I am working on an assignment for class: Create a program that allows a user to enter up to 10 addresses of friends. Use a two dimensional array to store the address of friends. After each address is entered, the user should have the option to enter another address or print out a report that shows each addresses entered thus far. I have created a code that is coming up without errors, but i am not getting the desired results.
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main ()
{
char name[10][10] = {0};
char address[10][10]= {100};
int choice;
[Code]....
My trouble is coming from the the output. I am able to fill the array but i am not able to print my desired results. Where am I losing it in the loop? Also after my first entry if i have space in the "address" input the program prints and ends.
View 6 Replies
View Related
Apr 29, 2013
What I'm trying to do is:
int *p;
someType memoryLocation;
cout<<"Enter your memory location: ";
cin >> memoryLocation;
p = memoryLocation;
cout << *p;
I was just messing around with some code, and was curious to if this was possible.
View 6 Replies
View Related
Oct 10, 2014
I want to store the address of a customer (with spaces) in a char variable (say cadd). First I tried to use "cin", as we know it reads until it sees any whitespace. So it reads only first word before a white space. So, I used "getline()" function, it will work. But when I used it, It did'nt wait for the I/P (it skipped it).
char cadd[20];
std::cout<<"Enter Customer Address:
";
std::cin>>cadd;
std::cout<<"Enter Customer Address:
";
std::cin.getline(cadd,20);
View 3 Replies
View Related
Mar 22, 2013
I have this data store into a data structure.
i j x y w h w*h
0 0 0 0 9 11 99
1 0 0 11 9 10 90
2 0 0 21 9 11 99
0 1 9 0 8 12 96
1 1 9 12 8 7 56
2 1 9 19 8 6 48
[Code]...
Code:
struct data {
//Here
/*! horizontal position */
int x;
/*! vertical position */
int y;
/*! width */
int w;
/
[Code]...
data and then i have an array /*! it contain group_id of each data line*/ int group_id[16]={0,0,0,0,3,3,1,1,1,3,3,2,2,2,2,1}; I never worked with 2D array before. My problem is that i want to create a 2D array of that data for example if i write data[j][i].. It will give me the reference/value of all data lines that belongs to j column, and same with group_id[j][i]. I don't know how i can store these structure vaules in this like 2D array.
View 2 Replies
View Related
Oct 14, 2013
Directions: Write a program that uses the structure named MovieData to store the following information about a movie:
Title
Director
Year Released
Running Time
Include a constructor that allows all four of these member data values to be specified at the time MovieData variable is created. The program should create. The MovieData variable and pass each one in turn to a function that displays the information about the movie in a clearly formatted manner. Pass the MovieData Variables to the display by value.
Code:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
struct MovieData {
[Code] ....
I sort of hit a wall did it do something wrong because the whole create two MovieData variables is confusing me.
View 1 Replies
View Related
Jan 16, 2014
I have one requirement to store an array of structure at shared memory. Also the shared memory should have one counter to store number of elements in the array.
I tried to look at some placed but didn't find anything relevant.
So my first question, is it possible that we can store two things on same shared memory. And second if not then how to achieve the same?
View 5 Replies
View Related
Apr 29, 2013
I am using Dev C++ compiler on Windows 7 and was programming a piece of code that is supposed to do the following -
Create a structure to store information about products for sale in a store. It should store information about the product name, the price, and the product number and then create an array of products called Inventory. Add five products to your inventory.
But for some reason, which is unknown to me, I always seem to get a compiler error. And this is what i have so far -
Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct product{
char name[30];
int product_number;
double price;
[Code] ....
View 4 Replies
View Related
Apr 6, 2014
My program is designed to read input from the user and then store that input in a structure variable. Whenever i use the cin.getline() function, it comes up with a semantic issue. Here is the code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const int DESCRIPTION_SIZE = 100, DATE_SIZE = 20;
struct inventory {
string description[DESCRIPTION_SIZE];
[Code] .....
I left out the other functions. The error reads "no matching member function for call to 'getline'.
View 6 Replies
View Related
Jan 5, 2013
I created a class (let call it X) which contains the structure to store the data from my data base. Them I have a class (call Y) which will contain a list for each row in my data base. Third, I have a class with thousands variables (Z). What I am trying to do is to take the list of objects (Y) that contains the data to initialize Z. What I want to now if I can do something like that.
Imaging that one of my rows contain the following data:
Type Nameofvariable etc...
"static const double; MNFAIL ; 0; 0; 0,25"
In my list I have a node with contain this data
I want to use the field Nameofvariable to initialize the variable called MNFAIL contained in my class Z.
Is it possible in C++
View 3 Replies
View Related
Aug 27, 2013
I am trying to run a programme implementing a function with structures in c... which is:
#include<stdio.h>
#include<conio.h>
struct store {
char name[20];
float price;
int quantity;
[Code] .....
View 1 Replies
View Related
Dec 7, 2014
Why doesn't this compile?
struct hi(){
void other();
}histructure;
void hi::other(){
std::cout << "Hi!" << std::endl;
[Code] ....
Makes no sense the structure is written before the structure member function is called so why is there compile errors ??...
View 3 Replies
View Related
Oct 7, 2014
Is it possible to assign a value to structure member inside the structure.like.....
struct control{
char tbi:2 =0;
char res:1 =0;
};
View 6 Replies
View Related
Mar 17, 2013
how I can create a structure that pointing to another different structure. And also passing structure to function.
View 3 Replies
View Related
Aug 2, 2014
Are Reference and Address same or Different?
View 10 Replies
View Related
Aug 14, 2013
So I obviously can't take the address of a bitfield, but is there a way to get the address of the field holding the bitfield? What I'm trying to do is find the address of the parent field of a bitfield in a class. For example
Code:
class Foo
{
public:
int a;
int b : 4;
int c : 28;
[Code] ....
My goal is to get the offset address of the int storing c in class Foo. But offsetof uses the address of c, so I get a compile error since c is a bitfield. What I wanted as output from the above would be "4", since an int is 4 bytes (on my system). So the int holding both b & c starts 4 bytes from the start of the Foo class. Is there any way to do this in c/c++?
View 14 Replies
View Related
Dec 7, 2013
I've run across this issue before, but for the like of me, I can't figure out what keeps causing it. The problem compiles and runs as expected; however in the salaried object (Employee #1 in main.cpp) the console displays the number of vacation days as -858993460 instead of the value entered.
The parent Employee class is abstract with calculatePay() and displayEmployee() being pure virtualls and with a Benefits, Salaried, and Hourly class derived from it.
The Salaried displayEmployee() and the portion of the Main.cpp that contains the salaried object follows. What causing this?
Salaried displayEmployee()
Code:
void Salaried::displayEmployee()
{
cout << endl;
cout << "Employee Information" << endl;
cout << "----------------------------------" << endl;
cout << "Employee Name: " << setw(7) << FirstName << " " << LastName << endl;
cout << "Gender: " << setw(12) << Gender << endl;
[Code] .....
View 2 Replies
View Related
Jan 31, 2014
I've got a problem with a piece of code that it doesn't seem to work anymore.
Code:
#include <stdio.h>
#include <conio.h>
main () {
[Code] ..... i
I chose a to be 5 and it displays the following:
"Type a value for a:
5
5 in octal is: 5
5 in hexadecimal is: 5
Process returned 23 <0x17> execution time : 1.031 s".I first saw this when trying to display the address of a pointer. Am i missing something? I used to run this code on dev-c++ successfully but after a day or so of practice, it's not working anymore. I switched from dev-c++ to code blocks.
View 5 Replies
View Related
Oct 1, 2012
So im trying to parse a string into a Ip Address but i have a problem, the IPAddress.Parse method only works for ipv4 address's how do i parse ANY Ip address into a string, if i use the IPaddress.Parse method on my public(remote) IP it throws an exception but on ipv4 local ip it doesn't how do i parse ANY ip address the user inputs as a string as an Ip Address?
View 5 Replies
View Related
Jun 21, 2014
C++: write a c++ program that will display your name, address and age..
View 3 Replies
View Related
Feb 20, 2013
When this programs runs it displays odd symbols for the address of the character. This is only part of the program, I took out the parts that already work.
#include <iostream>
using namespace std;
char again;
[Code].....
View 2 Replies
View Related
Feb 1, 2015
I'd like a function to return either a value or the address of that value by the users input. So he can call the function like:
function("adress") - gets an adress, or function("value") - gets the value
I've tried both function overloading and templates, but none of them worked. He might input a character for the address and an int for the value... but...
Another strange thing that i observed is that the value returned by the function below is 0, so the output is address 0.
class testing
{
public:
static int x;
[Code].....
View 2 Replies
View Related
Apr 3, 2013
Why can't I take the address of operators for primitives?
#include <iostream>
#include <string>
int main()
{
{
std::string (&plus)(std::string const&, std::string const&) = &std::operator+;
std::string a ("Hello, "), b("World!");
std::cout << plus(a, b) << std::endl;
[Code]...
[URL]....
I'm using this functionality in a templated class, do I really have to specialize for primitives or use std::enable_if?
View 2 Replies
View Related
Mar 10, 2014
Converting an IP address to a binary number? As in the entire thing 123.45.555.49 to it's binary equivalent.
View 14 Replies
View Related
Jul 2, 2014
I have a C-Power5200 driver. I want using the C# language change to the controller's IP address.
Here a link to the website and API.C-POWER 5200
In Annex API controller.
View 7 Replies
View Related