210 Topics
|
|
I am having some difficulty's locating an issue within some code I am working on. It breaks when it runs the "if (AIwords->name == NULL)" // This is the struct which is located in the header(.h) struct AIstruc_word { char *name; bool controlStatement; struct AIstruc_word *next; }; // This is … |
|
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 … |
|
So, I'm using allegro game programming library. Before I move on to bigger and better things I wnat to get a handle on pointers. Specifically with things like structs, linked lists and maybe binary trees in the future. I posted a program that uses a linked list to keep tracks … |
|
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) … |
|
warning: int format, pointer arg (arg 2) i have no pointers this function :( main.. functions.... functions. int test(char num) { int total[SIZE]; printf("%d",total); fflush(stdout); //no pointers return 0; } |
|
I am having a problem with an address book program. The problem is that when I try to set the fnTextField, lNTextField, ...etc I get null in all the JTextEdits. I've went through the debugger and before the I called `Edit edit = new Edit(1)` the values are in the … |
|
Basically i have made a binary class that inherits from a matrix class. and aparantly when i make the binary image the deconstructor doesn't work properly. the program runs, reads in the files and makes the binary matrix. However when the binary deconstructor and matrix deconstructors are called, the program … |
|
how to copy pointer to pointer. char *name1; //store the value of DAVE char *name2; if name2 was a array i would have done. strcpy(name2,name1); but i dont know how to copy pointer into pointer. i was thinking some thing like this. name2 = name1? also do i need to … |
|
I am having some problems working with the tell method when working with a file. Basically what I am trying to do is use the tell method to find where I currently am within a paragraph and to only display the characters up to a certain tell count. For example: … |
|
*i am trying to copy the value of ar2[10] //in main. has the value 1,2,3,4,5 in ar[10] //(in struct node). empty array so to copy the value iam not sure if i could use a strcpy for ex, strcpy(head->ar, ar2); //here is my code struct node { int ar[10]; //empty … |
|
trying to copy pointer in array. lets say *pointer has the value "COMPUTER". and i want to store in array[o]; note: i want to use strcat to do this and i do not want to do some thing like "array[0]" char test[10]; char *point; //has the value "COMPUTER" for(int i … |
|
I am importing some C code into a C++ compiler, specifically Borland C++ Builder 5. I seem to have a problem with this style of code: // A structure that contain's itself typedef struct AnObject AnObject; struct AnObject { AnObject *Object; }; // A global structure to store a pointer … |
|
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 (+, -, ÷, ×,%, ^ … |
|
Im having a lot of trouble figuring out whta's wrong in my code... it compiles and everything but every time I try to run the program it crashes before even starting and displays the following message: Debug Assertion Failed! Program: c:\CIS 278\MyString\Debug\MyString.exe File: f:\\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cpp Line: 52 Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) For information.......... … |
|
i want to create array of pointer. "aa" "ab" "ac" i tried many thing but it still give me error. char *table[3] = "aa", "ab", "ac"; or char *table[3]; *table[0] = "aa"; *table[1] = "ab"; *table[2] = "ac"; |
|
If anyone can help me finish this and point out what had to be done to make the program work, that would be great. -ask for how many days user wants to enter from 1-365 (validate) -ask for temperature for each days between -60 and 90 degrees celsius (loop, validate) … |
|
Here's a small snippet from my code. Following a Knuth Shuffle model in the Shuffle function, I get 6 Pointer Expected errors in line 15, but I'm sure its really 2 due to the SWAP function in the header. Now the two things I'm swapping are a random index and … |
|
Hi all. I am trying to build a Binary Linked Trie but fail in basic pointer operations.Following code can be built but in debug or run mode, it breaks and outputs the error. [ICODE]typedef struct node { char ch; node *next; }; struct node *root = NULL; void add(struct node … |
|
I programmed some functions that use a dynamic array of [CODE=c] double ** array [/CODE]. But know, I want to test the results with a small array of 5 x 5 elements and use this array in the functions I coded. My problem is that I can find no way … |
|
Could you please tell pictorially difference bw these 2 codes(o/p is same) and suggest any source where i can once in for all resolve doubts in pointer to pointer problems except "K&R in ANSI C" [CODE]#include <stdio.h> #include <string.h> void pointer(char**); void main() { char *p[]={"name","fame","claim"}; pointer(p); } void pointer(char … |
|
Hello. I am learning C++, and I am a little stuck. Right now, I'm working on pointers. The problem I'm working on requires sorting an array of structures, using pointers instead of array indices, using a selection sort. My code is not working, and I can't quite figure out why. … |
|
I'm new to using vectors and some may see this as a trivial problem. If you have any suggestion on how I can improve the program, I welcome your input. code(with problem): [CODE] #ifndef CMONOPOLY_HPP #define CMONOPOLY_HPP #include <vector> #include "head.hpp" namespace CMonopoly { class CMonopoly { public: ~CMonopoly(); void … |
|
Hi, I've been trying to learn what pointers are and how they function, and I now finally understand most of it. However, I don't understand the assignment of strings to a char *, and what the values they have mean. I wrote a small program to learn: [CODE]#include <stdio.h> #include … |
|
Hi all, My code for a function to count words is posted below, and the only error that appears when I build it in my compiler is that char present is uninitialized. My program will not run with this uninitialized value. I've been searching for info on how to initialize … |
|
Hello, I am asking about true syntax of the following:: I have a class name P and in header file (of this class) ------> [CODE] class P { public: P(); ~P(); void addItem(const int newItem); void deleteItem(const int Item); void showAll(); /** need to proper getter funct. of tail */ … |
|
Hi everybody, i am new to c++ and wanna know why pointers are useful ? Why would i use them ? For what ? THANKS |
|
Hello everybody I [I]thought[/I] I understood inheritance but it turns out I don't. I am creating an SDL/OpenGL mini-GUI library. I have a master class, GUIComponent, with subclasses such as TextLabel under it. I have a vector called guiList that is initialized as [ICODE]std::vector<GUIUnit*> guiList[/ICODE] (it's extern'd and initialized elsewhere; … |
|
Hello, I am trying to store data within a char in C. Different types of data will be used, for example, strings and integers. I have tried the following code: [code]char rawdata[4] = {0xfe, 0x01, 0x99, 0x42}; unsigned int *test = (unsigned int*) rawdata; printf("%u\r\n", *test);[/code] However, it returns the … |
|
In my program I read in a text file an decrypt the text from an array. once decrypted i then have to do through it again and search for every tenth array member and show their memory location. The code so far: [CODE] int main( ) { int* pCrypted = … |
|
class vector { int *v; int size; vector ( int m ) { v=new int[size=m]; for(int i=0;i<size;i++) v[i]=0; } vector( int *a) { for(int i=0;i<size;i++) v[i]=a[i]; } }; int main() { int x[3]={1,2,3}; vector v1(3); vector v2(3); v1=x; v2=y; return 0; } My doubt is , how can the constructor … |
The End.