210 Topics
|
|
please anyone help me to catch this.i tried to return an array from function and access it within main function.i just got a warning [CODE]"function returns address of local variable "[/CODE] and when i execute the program it gives garbage values as array elements..cam you help me pls... [CODE]#include<stdio.h> int … |
|
here's my code: [CODE=C++] #include <iostream> using namespace std; void func(int num) { num = num + 1; cout << num; } int main() { int num2 = 5; cout << num2; func(num2); cout << num2; func(num2); cout << endl << endl; system("PAUSE"); }[/CODE] when the program runs, it yields … |
|
While reading Stroustrup's "The C++ programming language", I was puzzled at 'declaring a pointer to an array of character strings and declaring a reference to an array of 10 integers', and I had to clear my mind on pointers to arrays. I am posting here the notes I made to … |
|
Hi, I created a program that makes a multiplication table, I dont know where the .txt file is located after executing the program Im using turbo C++ :-/ [CODE]#include<iostream.h> #include<stdio.h> void main(){ int multiplicand; int multiplier; int toprow; int column; int repeater; FILE* Starter=fopen("[COLOR="Red"]multiplication.txt[/COLOR]","w"); cout<<"Insert the number of repetitions: "; … |
|
My question is that what is the effect if I delete a pointer in a linked list by mistake??? What problems will arise and how will I come to know that is a missing pointer that is causing the trouble? |
|
My func looks like: [CODE]int pop(node **hd, char **new_element) { node *dummy; int i = 0; if (empty(*hd) == 1) { printf("Stack is empty"); return -1; } else { (*new_element)[i] = (*hd)->element[i]; // problem is here ;) dummy = *hd; *hd = (*hd)->next; free(dummy); }[/CODE] and I call it via: … |
|
Hi guys I'm struggling to write a code for traversing a directed graph. It contains City as nodes. I'm trying to put City(s) to a LinkedList and then work with them to find the path. However, as you will notice I'm still newbie in C++. I have a *nextcities as … |
|
I've searched all over google and this site. I've found a few hints here and there but after i make the changes either my compiler throws a fit or it doesn't produce the desired results. Here's what i want: I want to create a linked list in the main function … |
|
Hi,I have tried to get this program to work,but it works to the moment when you enter some of the array`s numbers and then crashes.In different sizes of the matrix you can enter different number of numbers,but for instance when the matrix is 5x5 the program crashes after the 11th … |
|
I'm rather new to the C programming language and I'm very stuck. Whenever I try to assign a value to dynamically allocated string, I end up with a Segmentation Fault. Could someone help me by explaining why this happens. Following is a bit of my code that I think should … |
|
I'm currently practicing algorithms and coding for my colleges programming team. The problem is, in High School I was almost purely C/C++, while my college team all work in Java. So, while not wildly different, learning Java is still pretty frustrating to me. My most recent problem is a Java.lang.NullPointerException … |
|
I did'nt understand here in this code i was reading a book and then const char *q="Hello"; //string is fixed pointer is not *q='M'// error q="bye"; //works char * const t="Hello"; //string is fixed pointer is not *t='M'// works t="bye"; //error so my question is in first if string is … |
|
Hi, I'm new to pointers. i got some requirements...... Following is my requirement.........i want to use a double and triple pointer array [2D,3D] and in that double pointer i want to get data from the user.how can i achieve that using malloc and free for assigning and deallocating memory. im … |
|
Hi guys I'm trying to finish my assignment, I stuck in a weird situation. I'm trying to create a pointer a linkedlist. This linkedlist contains pointer to a user-defined objects (City) and I'm trying to add City to this linkedlist and then iterate through the linked list to find and … |
|
I'm trying to do addition of matrices using pointers. But, in 3x3 matrix, only the first row of the matrix gets added, while the rest are zero. Please help me correct this. Thank You! My code is as follows :: [CODE] #include<stdio.h> #include<conio.h> int a[10][10],b[10][10],c[10][10]={0}; int i=0,j=0,k=0; int r1,c1,r2,c2; void … |
|
Ok I have a linked list which have to read from binary file and to write in binary files. This is the function about the reading from keyboard: [CODE]short readElement( Node * newE) { int b,e,m; if ( newE == NULL ) return 1; do { printf("\n Registration number:"); scanf("%s", … |
|
Hello, can someone please assist with my application... An automation system collects 512 measurement points per sensor. Each measurement point has dedicated OPC tag which I can read using OpenOPC for Python. However, with multiple sensors, the OPC server can lag. So, the automation system programmer created an "array of … |
|
Hi folks I'm trying to do my assignment in c++, I suppose to develope a maze traversal using backtracking algorithm. I have to write a constructor for my Maze with this sign. [CODE]Maze(**c, int size); [/CODE] which takes a n-by-n two-dimensional character array. Can you guide how can pass an … |
|
Hello List, I'm creating a Button where I want to add a function setActionOnReleased(func aFunction); From any class I'd like to instantiate this Button class and send it the function I want to execute. I found some reference to using member function pointers ( [url]http://bytes.com/topic/c/answers/569262-passing-function-argument[/url] ), but I'd like to … |
|
EDIT: I figured it out. I do not know how to delete threads. Sorry. I need to return a pointer to a new array. The new array must be the same as the old one, just in reverse. I have it all done except for one little part. I can't … |
|
Suppose we've got two integer and character variables: [CODE]int adad=12345; char character;[/CODE] Assuming we're discussing a platform in which, length of an integer variable is longer than or equal to three bytes, I want to access third byte of this integer and put it in the character variable, with that … |
|
What is the difference between pointer and reference Please explain in detail. I want its full concept , so pls explain in detail |
|
Hey there, I'm having trouble getting my program to display the students and class summary using classes. What I'm unsure of is where the problem lies, whether it is a displacement of set/get functions or the content in my StoreStudent function is incorrect, or perhaps something else I might have … |
|
I have an assignment that requires me to not use an array with [] at all throughout my code, read a file in a certain way, and I need a better understanding with malloc as well with pointers. The code with the [] is pretty easy for me, but pointers … |
|
#include<iostream> #include<string.h> int main() { char* str="my name"; /*plz explain what is pointer-name,and what is string- name here(realy confused) ? i am new to pointers :) */ int len=strlen(str); char* ptr; ptr=new char[len+1]; /*is this ptr pointer or string*/ strcpy(ptr,str); cout<<ptr; delete ptr; /*how this works */ cout<<endl<<ptr; /*this 'ptr' … |
|
Hi, I am developing a large scale code. In order to save the space, when I declare any pointer, I allocate it in another subroutine. Now it seems that it does not work when I use an array of pointers. I can summarize the code as: [CODE] #include "headers.h" /** … |
|
OK, I've got a [90][10] 2d array. I have a set of pointers that point to the values in the array by column. each column holds different info. It's a payroll file so the zero column of my array corresponds to an employee number. What I want to do is … |
|
Hey all! I'm writing a simple fluid game in C++, and I've come across a strange issue. I allocate a whole bunch of arrays of float for use in simulations. During the course of the program, nothing goes wrong. But when I try to delete the arrays, I get a … |
|
In my experiment.cpp i have Test *tests[maxTests]; as private data. How do i access this in my runExperiment function to call functions from the test class or its derived classes? |
|
Dear All, I am trying to use free function in C to free memory of an array of pointers. It does not work and I get segmentation fault. The code looks like this: [CODE] #include <stdio.h> #include <stdlib.h> int main() { int *make_pointer(int); void read_array(int *array[3]); /****************/ int *array[3] ; … |
The End.