All Questions
152 questions
1
vote
1
answer
414
views
type '' does not provide a subscript operator
The problem I have is with printing out spelare1[i] and the function kopaEnheter. I been going back and forward for a while so the problem might be else where. Have looked around for solution but ...
0
votes
1
answer
147
views
Calculating intensity for an RGB Color
i would like to ask how i can calculate my variable y for an RGB color intensity.
These r,g,b letters in my RGB_Trypel struct are representing each array element for the arrays rot, gelb, gruen, weiss,...
0
votes
0
answers
39
views
Accessing element of an array of struct inside a function in C
So i have defined my own struct to be
typedef struct counter_Nval
{
systs_t N;
uint16_t cntr;
} countN_t;
I pass a pointer to pointer to this struct to a function, since i need to allocate an ...
0
votes
2
answers
69
views
Why when I try to access array of structures it returns random values? (C)
I have a function that returns pointer to array of structures. However, when I try to access any of the values of returned structure, it prints random symbols.
#include <stdio.h>
struct MY {
...
1
vote
1
answer
52
views
Taking data from a function to use it in another one in C language
typedef struct Projet
{
/* data */
char theme[20];
int diff;
char etudiant1[4]; //L'Etudiant 1 affecté dans le projet par Matricule
char etudiant2[4]; //L'Etudiant 2 affecté dans ...
0
votes
1
answer
123
views
Passing a struct array and updating array in C++
For one of my options, I had to add a row of data to my struct array, I was able to update the array but it does not update the actual array. So I am trying to update my struct array by passing it as ...
-2
votes
2
answers
54
views
Error: expected primary-expression before ']' token. Need assitance with function definition and calling
This is my first semester of computer science, and I need help with my first project. So far, it's still a mess, and I am mainly doing test cases to ensure basic things like my functions work.
The ...
0
votes
0
answers
86
views
How do I pass an array of struct to a multiple functions?
I have three files. The struct to defined in the header file:
struct Person
{
string name;
char gender;
int age;
};
The second file called functions, contains 2 function. A simple ...
0
votes
2
answers
86
views
Can't Print array with multiple data types
I created a struct named products that contains multiple data types:
struct products{
int ID;
string Name;
double Price;
int Quantity;
};
Then in the main function, I created an array ...
-1
votes
2
answers
336
views
Change values in a struct array
Can someone explain me, please, why can't I insert values into a struct array.
Here's a piece of my code to help understand what I'm trying to accomplish.
I want to insert values inside an array which ...
0
votes
1
answer
38
views
In C, I'm having trouble getting an Index sorted High to Low and vice versa
I'm working on a project involving a preset array:
primaryArray[8] = {8, 4, 2, 16, 32, 124, 64, 256};
Im calling a function before the main, its not quite working. Here is the code.
void ...
0
votes
2
answers
82
views
How to pass a struct array to a function
I want to pass a struct array into a function, however, there's something wrong with how I'm passing it and I cant figure out what. I'll include the relevant code.
The Struct:
typedef struct fitbit
{
...
0
votes
0
answers
119
views
Why is one of my struct members undefined after attempting to change it in a function? I passed the struct as reference
I am writing code for a search_tree() function which fills a chArray struct (dynamic char array) with all the files in a directory and its sub-directories.
However, I'm having problems with the ...
0
votes
0
answers
63
views
Read the value of pointer to pointer array of struct passed to a function
Context:
Recently I've started programming in a more professional way and currently I'm working on a C driver library that should look decent in code both functionally and esthetically so I've just ...
2
votes
5
answers
141
views
How to pass struct array arguments to a function the right way?
Source Code:
#include <iostream>
using namespace std;
struct Employee {
string name;
int age;
float salary;
};
void displayData(Employee);
int main() {
Employee employee[3];
...