174 Topics
|
|
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* … |
|
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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 |
|
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. … |
|
-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 … |
|
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 … |
|
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 … |
|
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, … |
|
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 … |
|
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; … |
|
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; } … |
|
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 … |
|
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 … |
|
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; … |
|
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); … |
|
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, … |
|
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 = … |
|
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]; … |
|
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 … |
|
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 … |
|
[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 … |
|
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 … |
|
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 … |
|
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 , … |
|
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 … |
|
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 = … |
|
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 … |
The End.