210 Topics

Member Avatar for
Member Avatar for priyamtheone

I'd like to know how the following programme on pointer written in C can be written in C#, especially how to use the keywords in the C programme like &i and \*p in C#. Please clarify. #include <stdio.h> void f(int *p, int *q) { p = q; *p = 2; …

Member Avatar for JamesCherrill
0
114
Member Avatar for montjoile

hi there, I'm coding in windows, c++, but when I traslate my code to ubuntu, g++, I get this error: [B]lvalue required as left operand of assigment[/B] This is the line where I get the error: [COLOR="Red"][/COLOR][CODE]&*raiz=&*p;[/CODE] What could be the problem? *raiz and *p are pointers to an avl …

Member Avatar for Tushar_4
0
2K
Member Avatar for Bryan_5

I just started learning how to use pointer array and i'm trying out examples to know more about them but i get confused with them easily. So, I tried to do a simple arithmetic calculation using a pointer array. The user will input 2 string variables for addition. I then …

Member Avatar for deceptikon
0
352
Member Avatar for manaila

I have been struggling with this for two days now, with no luck. I have a **C** `char` array `char myArray[] = "Hello World";` I also have a pointer to pointer to *char* `char **ptr;` So I want to somehow store `myArray` to `ptr` or somehow convert `myArray`into pointer to …

Member Avatar for jacks009
0
312
Member Avatar for can-mohan

Hi All, I wanted to know in below code snippet what will be impact if m_singleObject is declared as a weak_ptr. Usaually we peform lock on weak_ptr and convert the same in to the shared pointer and then return the same to GetInstance() function. static std::shared_ptr<singleType> shareObject = m_singleObject.lock why …

Member Avatar for can-mohan
0
962
Member Avatar for can-mohan

Hi All, I just want to know whether use of shared_ptr is justified in below code here or do i need to use unique_ptr instead of shared_ptr? #include <iostream> #include <memory> using namespace std; class a { int a1 ,b; public: a(int x=0,int y=0):a1(x),b(y){} void fun1() {cout<<a1;cout<<b;} }; class b …

Member Avatar for madhav sai
0
183
Member Avatar for soujanya.bhat.184

Hi all, I was wondering how to access individual elements in the below case: char *three=(char*){'2','5','8'}; If the assignment were like this: char *three="258"; it can be accessed with three[0],three[1].....etc. How to access in the first case?

Member Avatar for rubberman
0
176
Member Avatar for sirlink99

Hello All, I am having trouble looping through a 2D array in C++ (should be very easy, but I am just starting C++). At the current moment I have this class file #include "Cube.h" #include <freeglut.h> #include <stdio.h> Cube::Cube(int cx, int cy, int cz , int cubeWidth) { int p[][3] …

Member Avatar for David W
0
465
Member Avatar for JohnMcPherson

I am having a problem with reading input data after checking a position marker in the data file. The code that does the reading follows: fip = fopen("fprmf.txt","r"); . . . strcpy(passw,"P7"); fscanf(fip, "%3s", ckod); /* card # 164 */ fprintf(ff16,"\n\n%12s%12s\n", "card# 164 :", "Password "); printf("passwd is %s\n", ckod); …

Member Avatar for Nutster
0
795
Member Avatar for Habib_7

I wrote this program that get words from user and if it was entered already it will print you loose but when I the first code crashs but the second code works! why the first code is crashs? #include <stdio.h> #include <string.h> int getword(char *word); int find(char * words[], int …

Member Avatar for David W
0
318
Member Avatar for furalise

Hi again everybody. I know there are some references to this kind of thing around the web but none of them are simple enough for me to understand. In my code below, I am trying to initialize a function pointer with a class member function but I'm not sure I …

Member Avatar for furalise
0
482
Member Avatar for exoruel

All of us started from being a rookie, and I'm one of those rookies who are new in this course. Maybe its time for you to share your expertise unto the newbies? Hope anyone might help me willingly in my program.Here's the problem: Use Pointers and Functions: Ask a user …

Member Avatar for David W
0
262
Member Avatar for kyle.mace.35

quick question how can I work around this char * dat = "08/11/2014"; char test[10] = dat; I need to be able to take a string and put it into an array of chars, how can i do this?

Member Avatar for deceptikon
0
221
Member Avatar for can-mohan

Hi guys, I want to access the element of structure from structure pointer using indexing for below code snippet. apart from this I also would like to know is there any way to find the type of member variable of structure on run time. #include <stdio.h> #include <assert.h> #include <stdlib.h> …

Member Avatar for Schol-R-LEA
0
226
Member Avatar for Gribouillis

This snippet defines a function [icode]mousepos()[/icode] which gets the mouse position on the screen. The package python-xlib is required.

Member Avatar for woooee
1
6K
Member Avatar for jkhippie

#include <memory> #include <deque> void MyFunc { std::deque< std::shared_ptr< Sprite* > > SpriteList; func_to_fill_deque( SpriteList ); for( auto i = SpriteList.begin(), end = SpriteList.end(); i != end; i++ ) { SpriteList[ i ]->spriteFunc(); // doesn't work SpriteList.at( i )->spriteFunc(); // also doesn't work } } void func_to_fill_deque( std::deque< std::shared_ptr< Sprite* …

Member Avatar for jkhippie
0
2K
Member Avatar for Labdabeta

Hello, I have learnt a few assembly languages (MIPS/x86/ARM/MIX) and I have a question about the call stack. Each of those languages uses a different method for subroutine linkage, and the way I learnt them was not conducive to recursion. Granted, if I continue reading my copy of The Art …

0
173
Member Avatar for fadoua_1

Hi, I created a structure Vector and implement some functions to make the new defined type (vector) dynamically allocated and resized (inspired from the C++ implementation of the dynamic arrays : vector). I need to assign a structure to every vector element but I am not sure that I am …

Member Avatar for Ancient Dragon
0
380
Member Avatar for admiri92
Member Avatar for Moschops
0
249
Member Avatar for CreatorZeus

So decided I should switch to VS13 for the added benefits. Copied the cold, transfered the files, alls good right? Wrong. Actually its not that bad. Just one main problem. `ltm` See this fella? This is the one guy that is standing in the way of me and the debachury …

Member Avatar for JasonHippy
0
240
Member Avatar for can-mohan

Hi, While executing below code i am getting error like "memory clobbered before allocated block" and due to this assignment is not happening. could you let me know what can be reason for the same. I do understand it is not good to use raw pointer but in current scenario …

Member Avatar for can-mohan
0
441
Member Avatar for ravi_14

![6b87dfe9bac7df6c309f7266d28a4ad0](/attachments/small/4/6b87dfe9bac7df6c309f7266d28a4ad0.JPG "align-left") i am reading "pointers in c by naveen toppo" .According to him program crashes when it encounter int y=*ptr; i dont understand why it should crash?i think its correct. *ptr gives int value. please refer attachement.

Member Avatar for Ancient Dragon
0
163
Member Avatar for ravi_14

i was reading a book and came across this line "C++ matches a pointer of any other type with type void * and prints a numeric representation of the address. If you want the address of the string, you have to type cast it to another type," please any one …

Member Avatar for Ancient Dragon
0
184
Member Avatar for kent.johnstone_1
Member Avatar for Start4me

I'm trying to zoom in on a Picturebox when scrolling the mousewheel, the code below zooms in on the image only to the center of the image, not at the current cursor position. How would I fix this? PictureBox1.Size = New System.Drawing.Size(PictureBox1.Width + e.Delta / 1, PictureBox1.Height + e.Delta / …

Member Avatar for Reverend Jim
0
2K
Member Avatar for chubbyy.putto

here is question: Write a function that accepts an array of integers and its size as arguments. The function should create a new array that is one element larger than the argument array. The first element of the new array should be set to 0. Element 0 of the argument …

Member Avatar for Ancient Dragon
0
328
Member Avatar for CoolAtt

Hi All, I got this code from a forum & tried it on g++/Linux. In the code below i put NULL to a pointer variable but didnt get any errors. #include <iostream> using namespace std; class A { private: int _dmember; public: void func() { cout<<"Inside A!! "<<endl; cout<<_dmember; // …

Member Avatar for CoolAtt
0
309
Member Avatar for Seba Sama

Hello, I came across a strange pointer (in my opinion): `void *(*foo)(int *);` Why are so many stars there? It was explained like: "...read inside-out; notice that the innermost element of the expression is *foo, and that otherwise it looks like a normal function declaration. *foo should refer to a …

Member Avatar for Seba Sama
0
220
Member Avatar for simran_4

Hello all, I am stuck with a nullpointerException at line 41 and 60.Can someone please help me out.any kind of help will be appreciated. Thanks import javax.swing.*; import javax.swing.event.*; import java.awt.Color; import java.awt.*; class calenders extends JFrame { int i=0; int j=0; int k=0; JFrame jf; FlowLayout fl; JPanel jp[]; …

Member Avatar for simran_4
0
557
Member Avatar for Sonu_2

How can I create an array of pointer using **P and point it to NULL? Let's say I have coded as below . struct s { float a ; char x ; } ; s **p ; p = new ( s * [10] ) ; Now I want to …

Member Avatar for richieking
0
329

The End.