Hi everyone; hope you are well. I have a small question: As far as I have searched, for example we can make integer variable defined outside the for loop private for multiple threads, but is it also possible to apply this situation for an integer pointer defined outside the for loop? I mean if a...
Sorry I don't have the codes right now.
In C plus plus, when I declare an int, but don't assign any value to it, a space in memory is allocated for it. I can define a pointer and check its adress in hexadecimal, so far so good. I can run this program over and over and usually the int is...
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *p;
p=(int *) malloc(4);
if(p==NULL)
{
printf("Insufficient memory");
return;
}
printf("Enter a number\n");
scanf("%d",p);
printf("Value of p=%d",*p);
}
1) What happens in background when we...
In this thread I attempt to find a closed form solution to the gradient descent problem for a single sigmoid neuron using basic calculus.
If you would like to give pointers feel free, if you see me make a mistake please let me know!
Thank you!
Hello.
I am supposed tolearn how to assemble the following circuit into a breadboard/protoboard
but My attempts have all failed So I want to ask yyou how would you assemble his into a breadboard assuming that V and A are multimeters set to the previous(V and A) . how can I get the gist on...
Hello! (Wave)
I have a question... 🧐
https://dyclassroom.com/c/c-passing-structure-pointer-to-function
At the Complete code stated at the site above, at this part:
for (i = 0; i < 3; i++) {
printf("Enter detail of student #%d\n", (i + 1));
printf("Enter ID: ");
scanf("%s"...
Why this doesn't work?
#include<iostream>
using namespace std;
int main()
{
int* p;
*p = 1;//error said uninitialized variable p used.
cout << *p << endl;
return 0;
}
I know if I do this, it works:
#include <iostream>
using namespace std;
int main ()
{
int* p;
int x...
@sysprog posted this code for a nifty swap function that uses XOR in another thread in this section.
This put me in mind of a couple of swap routines that I did awhile back: one with references and one with pointers. Unlike the example above, both routines do use a third memory location. Rather...
Hi
I wrote a program to copy an array of C-String into dynamic memory in the function using pointers. I think I did it right, but I cannot display without garbage at the end of the string.
//10.9 function copy C-String using pointer
#include <iostream>
using namespace std;
void strCopy(char**...
Homework Statement
I am supposed to analyze the code and find it's output without running it. Some things were unclear so i did run it and i have some things that puzzle me.
Homework Equations
3. The Attempt at a Solution [/B]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
enum e...
Hello, working on a puzzle and I think this may be what I need to do to solve it. I have a long string of characters,752 total with the range 0-9 and a-f. I believe that the data needs to be aligned based off the processor and memory. The Cpu is at 2800MHz and the memory is 1024MB. Is there a...
Homework Statement
I have to create a program that dynamically allocates a string and uses up no extra space (The string takes up as much space as it needs to),checks if entered string is 'please stop this', if it is then the prgogram exits and if it isn't then it continues, it makes a copy of...
Hey everyone,
I'm currently going over a chapter on pointers for my 2nd programming course (no prior experience outside of class). I'm wondering what the usefulness of pointers is, other than if you need direct access to the memory location of a variable.
The text essentially says it's good...
what is wrong with my programming D: won't print out the "Print"
#include <iostream>
#include <cstdlib>
#include<string>
using namespace std;
class Node {
public:
Node();
Node* prev;
string key;
Node* next;
};
Node::Node() {
prev = 0;
next = 0;
return;
}...
(mentor note: moved here from another forum hence no template)
This is the code with also the explanation of the exercise. There is bit of italian, but everything is clear enough.
I actually solved the exercise.
/*
Add an element of value n before each element of the list that satisfies the...
Dear Friends!
My post about dinamic arrays. For example little bit code.
// size
int const X = 5;
int const Y = 4;
int const Z = 3;
// one dimension array
printf("\nOne dimension\n");
// array of pointers
int * Arr;
// create array
Arr = new int [X]...
Homework Statement
So I'm getting an error when I try to compile my C++ code:
Debug Error
Abort() has been called
I have commented the code reasonably well, but the idea of the program is to take a file, separate the contents in each line to a part of a structure containing:
Product Lookup...
Homework Statement
I am to write a program that has its user enter 100 character or less and determine if the line is a palindrome or not. I must use pointers one that starts at the beginning and one at the end of the array that must work their way in until they meet.(I'm also having trouble...
Homework Statement
So I created two arrays one called departure_time and the other arrival_time and populate each array as follows. I've tried both putting 8 and defining N as 8
int departure_times[N]={480, 538, 679, 767, 840, 945, 1140, 1305};
int arrival_times[N]={616, 712, 811, 900, 968...
I am not sure that I understand the following:
http://www.cplusplus.com/doc/tutorial/pointers/
Why would someone pass an input to a function that he/she doesn't want to modify? And suppose that I want to do that, for example a function that runs a loop over N events determined within the main...
TTree* inputTree = (TTree*)source->Get( "<YourTreeName>" );
Could someone please explain me what the above statements mean? I don't understand what " (TTree*) " does (source is a TFile). Thanks.
Maybe I am going about this the wrong way.
I'm trying to build a form to display & update information in a object.
The objects are stored in an array since I'll have 1-N of them.
What I've done now is created an array of dictonaries which hold the information about the form fields, it...
Assign the first instance of The in movieTitle to movieResult.
Sample program:
#include <iostream>
#include <cstring>
using namespace std;
int main() {
char movieTitle[100] = "The Lion King";
char* movieResult = 0;
<STUDENT CODE>
cout << "Movie title contains The? ";
if...
I need some help understanding some things.
One, I understand WHAT pointers do but how are they useful and how/when are they necessary?
Two, what is the purpose of the flush function? This is the definition that I've been given: "The << flush forces cout to flush any characters in its buffer to...
Hi everyone. This is similar to my strcpy question previously. I tried to code but when I ran the code, a segmentation fault appears. I think this has something to do with my loop for the array but I have problems resolving it. May I have some help please? Thank you. My codes and the original...
I've been searching for a while, but all I seem to find is information about how it's illegal to sell laser pointers to minors in New York City. That and I find some information on what else is illegal to do with a laser pointer in NYC (pointing at vehicles, officers, etc.).
There's a lot of...
I have been going through a book on embedded development. I have been followin the C programs in the book with about 95% success as C is not completely new to me. But I am new to pointers so I was hoping someone would kindly clear a few things for me.
#define INPUT (*((volatile unsigned long...
I need some help with this piece of code I wrote earlier, it is compiling correctly but when I try to use my tester program it crashes.
I am trying to create an array of pointers to struct Nodes
typedef struct Node *NodeP;
struct Node
{
NodeP next;
EmployeeP info;
}...
"Pointers are variables that store address of another variable"
But I don't understand why such a thing was necessary. The only thing they are useful for is when we want to permanently change something passed to a function.
Since a function in C creates a local copy it only changes the value...
Homework Statement
Ok, I'm learning C programming and I'm trying to create a dynamic 2D array. This is the code that seems to work in creating a dyamic array. I found it in a book.
//rows and cols are values entered by the user when the program runs.
int **(matA) =...
I have done some "proofs" before in calculus. At this moment I am required to write proofs for linear algebra and I find them highly unintuitive and confusing -- I often don't know where to begin or what to do.
Can you guys leave some pointers, tips, advice, etc. for how to prove things...
Anyways, I will first start off by saying my name is Aaron Orszak and I live in Montreal, Quebec. Lately I've been really into things like computer programming (python and ruby mainly) but I sadly gave up on it because it just didnt fill the void. Right now I am really into electronics and want...
Hi,
I don't understand how this can be so difficult.
So I have a [char ** ptr] pointer that stores a list of arguments.
I'm able to PRINT each of them by doing printf("%s\n", ptr[i])
But how the heck do I is strcmp to see if a certain argument is there?
Apparently I cannot just do [if...
I aspire to getting into a reputable US physics grad school.
As I'm aware of so far (correct me if I'm wrong), there are 4 main things grad schools look at:
(in no particular order)
1. Your GPA
2. Your research experience
3. Recommendation letters
4. Your physics GRE score
Do any of...
Here is the given problem. I have a question for part c and e.
Calculate and print first 12 rows of the famous Pascal triangle, as shown below. Each number is the sum of the two numbers immediately above it. As our intent is to practice pointers, functions, loops, and dynamic memory...
Homework Statement
Create a function called isEqual(). isEqual() takes two strings and determines if the strings are identical. isEqual (s1, s2) should be the same as s1 = = s2
#include "stdafx.h"
#include <iostream>
using namespace std;
bool isEqual(int *s, int *st, int x);
int...
I wanted to make a variant on having a player just walking around a small 2d map. Instead of having 2 variables to store the current x and y values of the player position in a certain array, I want to make a 2d array that is filled with NULL pointers. Then the player would be represented as a...
If I need to write a c program which get a string from the stdin and prints it after a certain manipulation, the program is called that way:
echo "Hello, World. bla bla bla" | program <arg>
How can I save the string in my program before working on it?
Thanks in advance
Homework Statement
suppose i have class A.
now i have 2 derative classes: A_1, A_2.
i would like to create a 4'th class: Array_Class.
Array_Class will have 2 pointers array (one for each class - A_1, A_2).
i want to be able to get an object pointer from class A_1 or A_2, and place it in...
Hello all,
I am experiencing some odd output behavior from a program that I am working on:
Header file
#include <pthread.h>
struct ringbuf_t
{
pthread_mutex_t mutex;
pthread_cond_t cond_full;
pthread_cond_t cond_empty;
int bufsiz;
int front;
int back;
char* buf...
Homework Statement
There is a user defined function that looks like this:
void DisplayMenu(char *item)
My problem is that I have no clue on how I could include "*item" in my function, without changing the name or algorithm. The purpose of this function to to display the list of apps...
Hi, I tried compiling my program in Fortran using the following commands:
nagfor -g90 -C=all -C=undefined -g -gline -nan -u -mtrace=all test09b.f90 cell_functions.o -o test09b
I ended up getting this error message:
[Allocated item 15285 (size 17) = Z'FFFFFFFFB744A790']
Runtime Error...
Hey guys, I'm wondering.. If I were to reflect a green laser pointer to the mirror, will the reflected laser be hot too? Or will I be heating the mirror?
Can someone explain how the function queue::store(int i) (see attachment) works for a sequence of calls to it. Or give a reference to something or give a diagram, please.
Doesn't each instant (i.e., each memory location) have its own head, tail and next pointers as well as as the data member...
Hi,
I am looking at the following 2nd order DE with variable coefficient:
y''(x)-(1/x+7)y(x)=0
I would be grateful for any help in regard to methods which may be applied to such an equation.
Many thanks in advance!
C.
I'm trying to write a simple program to calculate the impedance of an AC circuit consisting of an arbitrary number of resistors, capacitors and inductors combined in series or parallel. First I ask the user to create the components they wish to use in the circuit, and this is where I hit the...
I've pretty much finished writing a CV which I intend to email to some prospective summer research placements at universities in London and possibly internationally. Some bits are nagging me though, for example:
In the education section I've listed my previous year grades, and my expected...
First of all, sorry for my bad english, it isn't my primary language. I'll try to describe the courses I have taken as best as I can, since the school system and courses names here might not be the same as everywhere else.
I completed college-level Physics I, II and III courses. Physics 1 was...