Questions tagged [declaration]
Declaration is the part of the subprogram (procedure or function) which provides the protocol(header), but not the body of the subprogram.
3,243
questions
0
votes
1
answer
44
views
Incompatible two void functions declaration
I have a problem about declaring two void functions in my template "Wallet" class, which are going to remove and add existing template class "CreditCard" to the vector. Compiler ...
1
vote
1
answer
16
views
Error 'listaCliente' undeclared (first use in this function)
I can't run the code because it gives the error mentioned in the title, but I declared it in main. I'm stuck for a few hours and I can't solve this
main.c , here is where I declare the "...
-1
votes
2
answers
62
views
Golang := operator for multiple variables [duplicate]
I'm starting using Golang as my main programming language to do exercises in LeetCode, and I get a strange result for Golang's := operator for multiple variables.
Let me say the question 104 to get ...
-6
votes
0
answers
67
views
How to initialize or declare a variable in C programming? [closed]
I'm working on one of my assignments in my C programming class and I entered everything right, but I can't figure out how to initialize the integers in this code. This program is supposed to output a ...
1
vote
3
answers
71
views
What is the reason of initializing a pointer to NULL if you will change later on its value to a valid adress?
I know that there are similar posts and that a pointer is initialized to NULL to avoid deferring a random address, but if a programmer declares a pointer is because he will use it later and assign it ...
0
votes
1
answer
29
views
C - use the struct name as the parameter of function in strcut
I'm trying to implement stack in c. this is my code:
//header file
typedef struct
{
ElementType Data[MaxSize];
Position Top;
int Push(SeqStack *L);
}SeqStack;
and this is what the ...
0
votes
0
answers
35
views
Is redeclaration of global objects legal or illegal in C? [duplicate]
In certain circumstances, the C language allows you to declare an object such as a variable without defining it.
This can be done using the keyword ‘extern’ or through the tentative definition rule ...
0
votes
1
answer
18
views
Declare WB as public where file name is based on cell value
I need help on declaring 2 workbooks globally where the workbook name is based on a cell value.
I have 3 workbooks workbook
"UPSHI" (file name does not change) workbook
"UAH DR_M04 ...
-2
votes
0
answers
51
views
What does it mean to declare a variable with {} in C++? [duplicate]
I have never seen this before. I cannot find any information as to what this means. What kind of declaration is this?
0
votes
1
answer
29
views
Exception has occurred: AttributeError 'str' object has no attribute 'tk'
i have some problematic python code..
import mysql.connector
from tkinter import *
import tkinter as tk
import sys
sys.path.insert(0,"/usr/lib/python3.9/site-packages")
import pymysql
...
0
votes
2
answers
31
views
error:invalide operands to binary + (have 'float' and 'float **')
void clc_moy_mdl(int n, int m,float *mt[3][30])
{
float s;
int i,j;
s=0;
remplire_matrice(n,m,tab,mt);
for(j=1;i<=n;j++)
{
for(i=1;i<=(m-1);i++)
{
...
-3
votes
1
answer
44
views
I have written my code (C programming) and all the input is working. However, it is not presenting the output. What am I doing wrong? [closed]
int main(){
int num1;
int num2;
int num3;
printf("Input the first integer: ");
scanf("%d", &num1);
printf("Input the second integer: ");
...
2
votes
0
answers
56
views
Is it valid to declare a variable without a name [duplicate]
I came across the following comment:
What is unsigned;
By looking at the declaration above I thought it is invalid. So to empirically verify this i tried the same with different compiler and to my ...
0
votes
1
answer
16
views
What does it change to declare a constant above or bellow a React functional component?
My question is what does it change to declare a constant above or bellow a React functional component (or a class component also) ?
for example what is the difference if I do :
const myName = &...
0
votes
1
answer
25
views
Getting error while trying to read filenames from array [closed]
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>
using namespace std;
int main() {
int numberArray[] = {};
int atoi(const char * str); /...
0
votes
0
answers
20
views
Determining An Array From Variant to Integer or Single or Long
I have a workbook with many procedures where I have just used Variant as the variable type for the array's I have since learned that this is time consuming in memory and I should instead determine ...
-1
votes
0
answers
23
views
What is the difference between declaring an array using "[]"or"{}"?
In Google Apps Script what is the difference between declaring an array using "[]"or"{}"?
For example:
function myFunction(){
var colors = []
var colors2={}
}
Thanks for any help
0
votes
1
answer
40
views
Force compiler to use static definition from a specific C file
Two C files have the same variable name declared differently.
Can I force the compiler (Visual Studio or gcc) to prefer one declaration over the other?
The scenario is that I have a C file where I ...
1
vote
0
answers
50
views
Inline out-of-class member function definition [duplicate]
struct S {
void foo();
};
inline void S::foo() {}
Can't figure out from the documentation if this function is considered inline or not. We use the inline keyword but in the definition of a ...
-1
votes
0
answers
24
views
declaration position problem in Javascript using Node.js
I wonder why the position of the declaration of variable matters in my code. It doesn't work depending on two different block scopes. Where can I get an idea to understand it?
const readline = ...
0
votes
3
answers
29
views
How can I make my class variable assignment dynamic?
In the following code, I want to assign an $settings's key, help to a constant class variable value, $To_default. However, I am told Constant expression contains invalid operations. Is there any way I ...
1
vote
1
answer
39
views
Solidity: Declaration Error: identifier not found or not unique. mapping(string=> team) teams; ^_ _^
This is my first time to write a computer programming language and it's a smart contract.
After finish, I pressed compile, and it shows the following error: DeclarationError: Identifier not found or ...
0
votes
0
answers
29
views
Are ranges in VBA not accepting Double declared value?
I have the following code where I pick a value from a named range and store it in a variable declared as a Double. Later on, after changing the variable or not I want to reassign it to the named range....
1
vote
1
answer
55
views
Check for NULL pointer doesn't work for char pointer
I know it must be silly to ask about, but my if statement that checks for null pointer doesn't seem to work. The code continues, and once I dereference the pointer, an error occurs. The code is kernel ...
-1
votes
0
answers
18
views
import type from REST API (typescript)
I have 2 projects using typescript:
api (Express.js + Typescript)
demo (Vite.js + axios)
How can i get return data type from api in demo. currently i rewrite the return type in demo as follows:
...
0
votes
0
answers
46
views
Numba Cuda declare array in thread without using (cuda.shared.array or cuda.local.array)
As a newbie in Numba Cuda, I wrote a numba cuda code. It turns to be very slow as long as i write into local array.
@cuda.jit
def kernel(......):
array= cuda.local.array((5,3), dtype=nb.float32)
...
0
votes
0
answers
37
views
change values of declaration variables in jsp scriptlet
Is that possible to change a variable's value from declaration jsp in scriptlet?
for example my code here doesn't change myV to b. Thanks.
<%!
public static class myC{
public static String myV=&...
0
votes
1
answer
30
views
SDL_Rect declaration with values not working
I'm studying a code that contains:
...
SDL_Rect rect(0, 0, 100, 50);
...
But when I do it, i get the following error:
error: expected declaration specifiers or ‘...’ before numeric constant
49 | ...
1
vote
1
answer
89
views
Can I initialize object of different types in an if statement? [duplicate]
I know I can write
if (int a = 1; /* whatever */) {}
and even
if (int a = 1, b{3}; /* whatever */) {}
but how can I declare, say, a of type int and b of type std::string?
Such a thing doesn't work:
...
0
votes
1
answer
33
views
This is my code , it keeps giving me this error : declaration error undeclared identifier solidity , did u mean "value"? line ( return _value)
pragma solidity 0.8.13;
contract student {
string public value;
constructor() public {
value="sami";
}
function set(string memory _value) public {
...
1
vote
1
answer
29
views
kotlin - unknown syntax in Jetpack Owl Example
trying to find some direction on how to select multiple items in a lazy column, I have found the following code in Owl Jetpack Compose example (Onboarding.kt).
...
val (selected, onSelected) = ...
-1
votes
1
answer
56
views
How do I initialize a struct in C
I got a comment on how I initialize my struct in C, saying that It does not work and it does not compile either.
This is how I create and initialize a structure in C.
struct {
int a;
int b;
char arr[...
1
vote
1
answer
80
views
Why don't we have to declare static functions the same way we need to declare static variables in c++?
Consider the following struct:
struct Toto {
static int a;
static void Print() {
std::cout << a;
}
};
And the following main function using the struct in the same cpp file (...
1
vote
2
answers
43
views
C11: Typedef of an anonymous struct works with pointers to the typedef as a member?
Here is how I would usually define a Node for a linked list in C:
typedef struct _Node {
int value;
struct _Node * next;
} Node;
With some testing, I have found that I am able to get this ...
2
votes
1
answer
44
views
can we give the number of elements in an array as needed using a variable?
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int L[n];
// ...
return 0;
}
I'm asking if I can give the number of elements in an array as needed ...
1
vote
1
answer
67
views
Compound Statement Expression In C
Below code is not working.
int i = {(void) 999; 100;};
Adding parentheses will work. WHY?
int i = ({(void) 999; 100;});
There is another way to do this type of assignment:
int i = ((void) 999, 100)...
1
vote
1
answer
44
views
compactMap() closure fails when adding irrelevant NOP declaration?
Playground
XCode Version 13.3 (13E113)
Swift 5.6
First print of compactMap() closure displays this:
["What\'s", "Going", "On?"]
The second print displays this:
[(), (), ...
2
votes
1
answer
55
views
Incompatible pointer types warning when printing function pointers
I am trying to create an array of function pointers, so that I can print out output from the functions by using the pointers. (For an exercise from the Effective C book.)
#include <stdio.h>
#...
1
vote
1
answer
27
views
Typedef in c, how it works when it takes 2 arguments
Can anyone explain to me how this code snippet works?
typedef int (*compare)(const char*, const char*);
1
vote
2
answers
64
views
How to reverse every string in an array of strings through a function in C?
I have been trying to solve this issue for whole day, and could not do it on my own. Searching the internet didn't help me solve it either
So, this the function prototype:
void invert(char **arr, int ...
-1
votes
1
answer
57
views
Why did I write the declaration into the main function that the program does not run [duplicate]
When I write the following three lines of code into the main function, the program will not run.
const int N = 500005;
long long a[N]={0};
long long b[N]={0};
At first, I thought it was a problem ...
0
votes
0
answers
8
views
How do I stop the output from being printed in jshell
How do I stop the output being printed?
I don't want it to be like this
i=15
$1==15
I just want it to be processed without the output being printed
I tried looking everywhere and trying new lines of ...
0
votes
1
answer
62
views
How do you write a declaration in racket that returns either a string or #f (false)?
I have the following function in racket:
( : search-stack : Symbol KeyStack -> String)
(define (search-stack s stack)
This function searches the stack for a specific string and returns the matching ...
0
votes
2
answers
57
views
Is this a syntax error or an error with the compiler?
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char charName[] = "John";
int charAge[] = 35;
printf("There once was a man named %s\n", charName);
...
1
vote
3
answers
73
views
C: Constant length doesn't allow me to declare array
I'm experiencing this annoying issue when I try to compile a simple code to understand pointers.
Basically, the error happens in the declaration of the array:
// Use of pointers
#include <stdio.h&...
0
votes
0
answers
21
views
Declaration of Colums in 2d Array with Apps Script
I have an CSV Data in which I have Data which is a Number, but if I import ist into an Arry in Apps Scripts it will not be recognized as an Number. Its recognized as "NaN".
How can I format ...
-2
votes
2
answers
72
views
Declare static array in class with size passed to constructor?
Is there any way, to declare static array in class with size that was passed to constructor? It is alright if the size has to be const and it makes it impossible to set it in runtime.
I tried doing ...
-1
votes
1
answer
56
views
whats the difference between vector<int> arr[n] and vector<int> arr(n) [duplicate]
#include <bits/std c++.h>
using namespace std;
int main () {
int n; cin>>n;
vector<vector<int>> array[n];//idk what this is`
vector<vector<int>> arr(n);//this means ...
2
votes
1
answer
82
views
Why were parentheses disambiguated as a function declaration with std::istream_iterator? [duplicate]
auto queue = [](string str) {
istringstream ss(str);
//std::copy(std::istream_iterator<string>(ss),
// std::istream_iterator<string>(),
// std::...
0
votes
1
answer
39
views
How to initialize a variable that will eventually be set to the response of an async request in Typescript?
Being relatively new to typescript, I've run into a problem that I didn't face in my first project - when declaring a variable prior to an api request inside a try-catch seems to throw typescript ...