174 Topics
|
|
//Bubble.h #include <iostream> #include <fstream> #include <cstdlib> using namespace std; struct nodeType { int info; nodeType *link; }; class Bubble { public: Bubble(); //constructor //deconstructor //copy constructor //operator= (overloading the = operator) friend istream & operator>> (istream &infile, Bubble & mylist); friend ostream & operator<< (ostream &outfile, const Bubble & … |
|
Hi I have trouble with implementing a dynamic two dimensional pointer array on allocating memory for it. I tried it this way but not sure if it's correct. The array should contain pointers to heap allocated **Integer** objects const int size = 10; Integer *** twoD; twoD = new Integer**(); … |
|
#include <stdio.h> #include <ctype.h> #include <stdlib.h> #include<conio.h> #include<iostream> struct list { int data; struct list *next; }*L; //function declaration: void create(int data,struct list **head); void print(struct list **head); int main() { //list *L; int data =10; for(int i=0;i<3;i++) { //struct list *pList = NULL; create(data++,&L); print(&L); getch(); } } void … |
|
ok so as a homework assignment I have to sort a c-string array alphabetically. We have to use pointers and cannot using strings (although strcopy and strcmp can be used). I can sort integers and strings but for the life of me cannot figure this out. I'm pretty sure i'm … |
|
Hi I have a quick question about a program im writing. The bold part is where im stuck. As of now my output is correct. Just wondering how to delete the memory I allocated. The question asks: Let us say that you want to choose how many marks to enter … |
|
I am studying the C++ code from an opensource project (libredwg) I have the following code: `*offset = *(*src)++;` What does this do? I understand offset = *src++; which would assign src[0] to the variable 'offset' and then increment src so that it points to what was previously src[1]. |
|
So I'm trying to right a code to output some simple data using classes. Everything works accept the retail price function. It's suppose to calculate and output the retail price but it only outputs 0 no matter what numbers I eneter. Can anyone give me some suggestions on how to … |
|
Hey all, this is a pretty basic program that will take a use submitted array and call functions to find the max,min and then a function to reverse the array. I have the first two functions written and working but I am having trouble with the reverse array function. The … |
|
This is a basic question, but I can't seem to understand how this works: Suppose I pass a structure pointer to a function, do I need to malloc memory for this passed pointer inside the function? e.g., typedef struct example_data_ { int serial; char *name; } example_data; int main() { … |
|
Hi there I have a question about pointers, i have a functions that takes a path to a txt file, extracts whats in it into an array and returns the array. As i understand it you can't actually pass the array, you have to return the pointer to the array … |
|
I am trying to build a tic tac toe program for an assignment. My trouble is making a dynamic array, I am new to c and my understanding of pointers and malloc is still very limited. I would like a resource I could read or an explination of how malloc … |
|
char str[]="qwerty"; char *p="qwerty"; str++; \\error *str='a'; \\works p++; \\works *p='k'; \\error whereas, char str[]="hello"; char *p="hello"; str="tell";\\ error p="tell"; \\works strings point to themselves like arrays then why is str="tell"; \\error an error?? is the case same for arrays?? please explain the reason for every line. also, why can't … |
|
i want to know why the runtime error is coming in this code????? #include<stdio.h> #include<conio.h> #include<string.h> int main() { char *a,*b; scanf("%s",a); printf("%s",a); return 0; } there was no error when a declared first pointer i.e. a but as soon as i declared the 2nd pointer(b) i am getting a … |
|
Write a program that opens a file, reads records into a container of data structures, and prints out the sum in order. You can use Vectors to contain the data structures. 1. Create a data structure to represent the record (struct cost in cost.h) 2. Write a function called parse_account … |
|
Hi everyone, I was wondering if anyone could help - I'm trying to split up a char* that contains a string, something like "*Stephen*10:11:00*02/07/2012*Hi there" I'm trying to split it up so it gets the position of the first * then the second, and stores whats between them in name … |
|
Hey there, I'm having issues with a custom string tokenizer I'm using for an assignment. I've looked around and haven't managed to find anything that really answers my question, so here goes nothing. Whenever I run the program and it runs the tokenizer, I get a seg fault. I'm fairly … |
|
hi im studing on i have this work and its giving me this error: main.c||In function 'get_jogos':| main.c|75|warning: implicit declaration of function 'get_endereco'| main.c|75|warning: assignment makes pointer from integer without a cast| main.c|76|warning: assignment makes pointer from integer without a cast| main.c|122|error: conflicting types for 'get_endereco'| main.c|75|note: previous implicit declaration … |
|
Hi everyone,I'm tryind to do something about sound on linux.I basically record some sound and try to encyrpt it using algorithm.However,I encountered some sort of pointer problem.Both RSA algorithm and recording&listenin sound works properly. Here is my code: /* * rsa.c * * Created on: 24 May 2012 * Author: … |
|
Hi everyone, At the moment I'm trying to create a class that contains a DOMNode* pointer, something like this class MyDOMNode { public: MyDOMNode (DOMNode* node) : mDomNode (node) { } bool operator== (const MyDOMNode& rhs) { if (mDomNode == rhs.mDomNode) return true; return false; } bool operator!= (const MyDOMNode& … |
|
I want to use opengl to draw some stuff, not to the screen but to a data buffer instead. Is this possible? IE: uint32_t *data; glSetDrawTarget(data,GL_RGBA|GL_UNSIGNED_INT_8_8_8_8);//this is the line I cannot figuro out how to do glBegin(GL_TRIANGLES); //... glEnd(); //and now my buffer is full of custom data glSetDrawTarget(NULL,NULL);//reset to … |
|
Hi there. I am having some trouble trying to figure out how to delete a pointer that is held in a vector. int main() { vector<Test*> iVector1; vector<Test*> iVector2; vector<Test*>* pVec1(&iVector1); vector<Test*>* pVec2(&iVector2); pVec1->push_back(new Test(11)); pVec1->push_back(new Test(12)); pVec2->push_back(new Test(23)); pVec2->push_back(new Test(24)); //delete iVector1.at(0); delete iVector1[0]; iVector1.at(0) = new Test(21); pVec1->at(1) … |
|
How to make this program #include <stdio.h> #include <conio.h> #include <math.h> int main(){ clrscr(); for(i=0;i<10;i++) for(j=0;j<10;j++) printf("a[%d][%d] = %d \n",i,j,a[i][j]); printf("cu pointer\n"); for(i=0;i<10;i++) for(j=0;j<10;j++) printf("a[%d][%d] = %d \n",i,j,*(p+i)); getch(); } int a[4][4],b4[3][3],b1[3][3],b2[3][3],b3[3][3],n,c1,c2,c3,c4,i,j; printf("\nIntroduceti elementele Matricei cu 4 linii si 4 coloane: \n"); int *mat; n=4; for (i=0; i<n; i++){ for … |
|
Hi everyone, Was wondering if anyone could help... I know the std::map automatically sorts it values - I have a map a Date object pointer, and a bool for whether it is to be used or not. But I need the dates to be in order from earliest to latest … |
|
I have not found anything that addresses these questions. Any help is appreciated. If I have a class that has pointers to objects of a user-defined class as members, is there any problem with initializing those pointers with the initialization list of the constructor? For example, where A, B, and … |
|
Hi, I have read something on IBM's site about exception specification and pointers to functions: void (*f)(); void (*g)(); void (*h)() throw (int); void i() { f = h; // h = g; This is an error. } IBM says: > The compiler allows the assignment f = h because … |
|
I am having trouble with this part of my program assignment. I have created and compiled the three separate implementation files that design the three classes, they each have a default constructor, overloaded constructor, and a display function. //************************************************************************************************************ "When your program is working correctly, define an array of pointers … |
|
Hello! I started learning C++ and I just discovered pointers. Well, it's a little bit hard for me to understand what's the point of it so I'll just explain my problem. I want to create a code in which I compute results using arithmetic operations (+, -, ÷, ×,%, ^ … |
|
Hello, my question is this. In C++, how do i call a method member of class A from a class B, using a pointer. By the way Class A and B are of different types. I read that when a pointer is pointing to member function it can only point … |
|
why is the output of the below program is coming out as 'unequal' ??can anyone please explain?? #include<stdio.h> void func(char *); void main() { char *q; char *p; p="hello hii"; func(q); if(p==q) printf("equal"); else printf("unequal"); } void func(char *pi) { pi="hello hii"; } |
|
I was asked to create a program that enters numbers and displays the before sorting order, and the sorted order displaying the previous node address and the next node address. I was told not to swap the data inside the nodes, but move the nodes themselves. I have a problem … |
The End.