174 Topics

Member Avatar for
Member Avatar for dgreene1210

This is my header file i want to use [CODE]#include <stdio.h> #define my #define LABOR_COST 0.35 #define TAX_RATE .085 void read_data(int* length, int* width, int* customerdiscount, double* costpersquarefoot); void calculate_values(int length, int width, int customerdiscount, double costpersquarefoot, int* area, double* carpetcharge, double* laborcharge, double* installedpricecharge, double* discountcharge, double* subtotalcharge, double* …

Member Avatar for gerard4143
0
167
Member Avatar for arunkumars

Hi, Am trying to use pointers on structures in c#. A separate class file. (the class file contains only strucutres, and the class has been removed. [code] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct strEmployee : INotifyPropertyChanged { [MarshalAs(UnmanagedType.Struct)] int _EmpNo; public int EmpNo { get { return _EmpNo; } set …

Member Avatar for sknake
0
350
Member Avatar for king03

Can someone please explain to me how the pointers were used in the line w/ the red font. I do not understand where the pointer pertains to and why there is still a need for that. Also why is it that a "+" sign was used to combine two array …

Member Avatar for Ancient Dragon
0
133
Member Avatar for bravo1382

Hello all, I am fairly new to c++ and I am completely lost right now. I am suppose to create two dynamic arrays that prompt the user to enter how big the arrays should be and it also asks the user to enter the numbers they want to store in …

0
97
Member Avatar for kangkan_14

Here is a part of code I am writing.I am getting a segfault in the CmpFunc function. The segfault occurs when I compare *a and *b i.e in the "if(*a>*b)" line. I am new to function pointers. So, I might be making a mistake somewhere which I don't realize.I would …

Member Avatar for kangkan_14
0
2K
Member Avatar for now how abt tht

please help me understand when does one use *n=m and when to use n=&m [code]int *n,m; *n=5; m=2; *n=m;[/code] //gives an error

Member Avatar for jnawrocki
0
131
Member Avatar for termin8tor

Hey all, I'm attempting to use an STL List to store a list of objects. Now I realise it's quite trivial to store a list of objects of my own definition. My real question is, how do I fill the list with objects that inherit from a base class. E.g. …

Member Avatar for termin8tor
0
267
Member Avatar for dgreene1210

-The program should print "COP 2220-50184 Project 3: <your name>" with a blank line before and after. -Then it should prompt the user for the input file name of the file containing the data to sort. - If the program can't open the file or if no file name is …

Member Avatar for TrustyTony
0
260
Member Avatar for ShadowBorn

I have this assignment due and its a bit tricky, i was wondering how is it possible to incoporate both C-string and a [I]string[/I] object at the same time. Any help would be very very appreciated. thank you all in advance. Here is the actual problem from the book. [B]Write …

Member Avatar for NathanOliver
0
142
Member Avatar for Mahkoe

I have a union named un. I have a un* named up that is the address of a un named u1 (bear with me). The pointer works fine, but I can't pass it to a function. Any alternatives? Here is some code to illustrate (please tell me if there is …

Member Avatar for Mahkoe
0
1K
Member Avatar for quetzal_7

Hi, help please! I have a struct containing an array of pointers to structs containing Binary Search Trees with nodes containing structs. ... <*sigh*> I hate C soo much... put work wants it to be in C. I can set the struct of BST's just fine, and keep it around, …

Member Avatar for Ancient Dragon
0
205
Member Avatar for sajay

Hello I'm coding an algorithm based on genetic programming with tree structures in C. I implemented tree structure using recursive structure pointers **The traditional way** [CODE] struct tree { int val; tree *left; tree *right; }; tree a[10]; tree b[20]; void main() { generate (); // this generates me 10 …

Member Avatar for sajay
0
186
Member Avatar for ctrlaltcasper

Ok this is my situation I have this header file: [CODE]struct dir { char name[3]; int root_dir; int has_children; int num_children; int offset_to_children[2]; int offset_to_files[16]; }; struct files { char name[5]; int size; int offset_to_beginning; int has_fragment; int next_fragment; }; struct fat { int files; int dirs; struct dir *dir_array; …

Member Avatar for Ancient Dragon
0
217
Member Avatar for bensewards

Hey everyone, I have to manipulate two functions RECURSIVELY, strlen and strcpy. I was able to code the strlen: [CODE]int length(char* str){ if(str == NULL){ return 0; }else{ return length(str, 0); } } int length(char* str, int l){ int len=0; if(str[l]){ len = length(str,l+1); } else { return l; } …

Member Avatar for bensewards
0
746
Member Avatar for geir88

Hi, I've got an assignment at school that I would really like help with. I'm a total newbie. [code=c]#include <iostream> using namespace std; int main() { char chr=(char)67; unsigned int offset = 1000; char * ptr=(char*)0; ptr+=offset; cout << ptr[0] << (char)43 << (char)(chr-24) << endl; } [/code] The questions …

Member Avatar for Fbody
0
108
Member Avatar for globberbob

Hey there, working on a program thats going to have a bunch of functions, but for now I am stuck on something that will be reused throughout the program alot: passing a string pointer to a function. It may seem redundant or arbitrary that I am passing it as a …

Member Avatar for globberbob
0
7K
Member Avatar for Buffalo101

Hello, This is an extension of this thread: [url]http://www.daniweb.com/software-development/c/threads/357681/1525001#post1525001[/url] My purpose is to create a class that handles a network message. Irrelevant, anyway. CMyMessage: [code=C] #include "stdafx.h" #pragma once #include <conio.h> #include <stdio.h> #include <iostream> #pragma once using namespace std; typedef unsigned char byte; class CMyMessage { protected: byte type; …

Member Avatar for Buffalo101
0
682
Member Avatar for Buffalo101

Hello, My program looks something like this: [code=C] char *name= (char *)malloc(200); unsigned char type=1; unsigned char GetType(){ return type; } char* GetName(){ return name; }; void function(unsigned char* message, int* intPtr){ message[0]= GetType(); // works correctly // CODE HERE } void main(){ unsigned char *message= (unsigned char *) malloc(256); …

Member Avatar for gerard4143
0
396
Member Avatar for mars001

I was trying to input an array of strings using pointers but failed. Here is the code: [CODE=C]int i=0; char *p[6]; //array of strings for(i=0;i<5;i++) { gets(p[i]); // input string } for (i=0;p[i];i++){ printf(p[i]); // print string printf("\n"); }[/CODE] The problem is that each time the first for loop executes, …

Member Avatar for mars001
0
225
Member Avatar for ritu143

Hi, I am new to c++, facing difficulty in compiling the following code [CODE]#include <iostream> #include<string.h> using namespace std; class myclass { public: int i, j, k, *l; // accessible to entire program static int *m; }; int myclass::*m = NULL; int main() { myclass a, b, *p; a.i = …

Member Avatar for rubberman
0
2K
Member Avatar for ajcc103

Hi, I'm stuck on something and was wondering if I could get some advice! OK I'm passing a double *array1 and a double **array2 to a function pointer array like this: [CODE]void func1(double *array1, double **array2, int i){ array2[0][i] = array1[0]; array2[1][i] = array1[1]; array2[2][i] = array1[2]; array2[3][i] = array1[3]; …

Member Avatar for gerard4143
0
175
Member Avatar for java beans

Im trying to to create a simple 4 function calculator using a jump table without switch case or if/else statements. I understand I can create the jump table via function pointers but I am kindda blanking out. I've started with the addition and subtraction part of the program but am …

Member Avatar for JamesCherrill
0
413
Member Avatar for dooleyis

Hi everyone, I was wondering if it is possible to point to a textbox created in the form designer via a string variable. Basically, I'm creating a golf management system with a feature allowing a user to define their own course. Each hole has a corresponding textbox into which a …

Member Avatar for dooleyis
0
210
Member Avatar for spoonlicker

[B]Okay, I finally understand that they point to memory, because I knew that all along. I just wasn't aware of why they needed to point to memory for. So I need to use pointers in this position but I don't know where to use them or on which things and …

Member Avatar for papanyquiL
-5
229
Member Avatar for fishsicles

Hello, I am working on developing an interpreted programming language for a capstone project and have hit a snag dealing with two classes. In the interpreter, the classes represent a scope containing a procedure pointer and the procedure pointing back to the scope containing it. The former to allow the …

Member Avatar for fishsicles
0
141
Member Avatar for Lord_Migit

Hey folks, just a quick question i can't seem to find the answer to. If i overwrite a container with a pointer in it, does the pointer and therefore the object it points to still exist, and would that be considered a bad handling of memory. For instance. I have …

Member Avatar for Lord_Migit
0
138
Member Avatar for barevhayerable

hello everyone.. please answer me , if you can give me working code I thought about something... I know that everything in our machines have addresses.. I thought about watching everything in my computer's random access memory(RAM) But I don't want to see the information in view of garbage , …

Member Avatar for Ancient Dragon
0
193
Member Avatar for JDevelop

Hello there, I've just started on C and what I'm trying to do is copying one string to another (which has not been initialized before) without using any string.h functions. Here's my code. [CODE] #include <stdio.h> #include <stdlib.h> void copyString(char*,char**); int main(){ char* string1="Hello there"; char** string2; printf("string1: %s\n",string1); printf("Copying …

Member Avatar for JDevelop
0
274
Member Avatar for BanKuZ

hi all, I have a class A that has a char* var, operator and methods. In addition I have a global func(char*s). I would like to run this code from the main function by adding operators to my class, I need help writing them. [CODE]A* pA; ... A** ppA = …

Member Avatar for BanKuZ
0
253
Member Avatar for whodoes21

Hello citizen of Daniweb may I ask a little help from you guys please :) see there's this program that our professor had asked us to make and It's about pointers. as a newbie to this world I was able to (gladly) make it but i feel like it could …

Member Avatar for whodoes21
0
195

The End.