Skip to main content
Filter by
Sorted by
Tagged with
2 votes
3 answers
275 views

Given this function: int f() {return 10;} void(f()) defines a void f() and doesn't compile with the following error: 'void f(void)': overloaded function differs only by return type from 'int f(void)'...
Bagheri's user avatar
  • 39
5 votes
1 answer
173 views

Can function declaration in a function scope have a locally defined constant as default argument? For example, void f(int) {} int main() { constexpr int c = 1; void f(int = c); f(); } ...
Fedor's user avatar
  • 24.7k
4 votes
6 answers
271 views

So my professor gave us the assignment to code a function that works exactly like strcmp() but without using any library functions. I came up with the following code but instead of returning 1 or -1 ...
Nebelmonster's user avatar
0 votes
2 answers
94 views

I would like to use values within variables for defining functions in R. However, after declaring the function I can still see the variable names instead of their values inside the function definition....
Imsa's user avatar
  • 199
4 votes
2 answers
141 views

There are (source): void f(); // declaration (1) void f(void); // declaration with prototype (2) void f() { ... } // definition (3) void f(void) { ... } // definition with ...
Sinatr's user avatar
  • 22.3k
2 votes
3 answers
98 views

I am hoping to get some help with understanding why function definitions, with function pointer return types need to be written the following way. int ( * functionFactory (int n) ) (int, int) { ...
Tim's user avatar
  • 169
5 votes
2 answers
187 views

Is the following a standard C function declaration according to ISO/IEC 9899:2017 (c17)? int foo(int (bar), int (baz)); If so, please point me to the section in the standard that defines this. In ...
GandhiGandhi's user avatar
  • 1,573
2 votes
1 answer
157 views

INTRO I am writing a class stalker<Obj> that holds inside a variable of type Obj. I want that stalker<Obj> to pretend that it is almost the same as Obj variable (from the user's ...
Alexander S's user avatar
1 vote
1 answer
63 views

this is my code: #include <stdio.h> int getsum(int a,int b){ return a+b; } void fun1(int a,int b,int (*c)(int a,int b)){//Standard writing method int sum=getsum(a,b); printf("%...
zhan Wang's user avatar
4 votes
2 answers
405 views

This question builds on this one, which describes how the following are equivalent: int f(int a[10]) { ... } // the 10 makes no difference int f(int a[]) { ... } int f(int *a) { ... } In ...
user615536's user avatar
2 votes
1 answer
56 views

I have a C library for which I'm trying to create (out-of-line, API mode) CFFI bindings. The C library provides various implementations of each function, but all of them have this giant, obnoxious ...
JamesTheAwesomeDude's user avatar
1 vote
2 answers
193 views

As I read through C code, I often times see this: int main(int argc, char **argv) but I always learned to do this: int main(int argc, char *argv[]) So, why would I use one over the other? I know ...
R-Rothrock's user avatar
3 votes
3 answers
316 views

Recently I came across a surprising way of defining a function pointer in C: typedef void (func_type)(void); func_type *func_ptr; Is this a correct way of defining a function pointer? If we define ...
mrn's user avatar
  • 1,093
1 vote
2 answers
149 views

Suppose we have many C functions with the same signature and return type: R f(X x,Y y){...} R g(X x,Y y){...} R h(X x,Y y){...} where X and Y are the types of the arguments and R is the type of the ...
ngn's user avatar
  • 7,922
91 votes
4 answers
9k views

In gatomic.c of glib there are several function declarations that look like this: gboolean (g_atomic_int_compare_and_exchange_full) (gint *atomic, gint ...
Andreas's user avatar
  • 10.4k
6 votes
2 answers
182 views

For the code: int hi(int); int hi(); int main() { hi(3); } I don't get any compilation errors (calling hi(); without arguments does get a compilation error). I expected that the compiler would ...
arye's user avatar
  • 511
0 votes
2 answers
112 views

can anyone help? why '&' is not required while calling a function in this program? but is thought that '&' is required in call by reference. #include <stdio.h> #include <stdlib.h> ...
Mohan Singh Bisht's user avatar
1 vote
1 answer
97 views

I have this code: #include <stdio.h> void replaceIndexElement (int index, int element); int main () { replaceIndexElement(2, 3); return 0; } void replaceIndexElement (int index, int ...
emblox's user avatar
  • 37
2 votes
1 answer
88 views

Goal: In a C module that manages display of text, I'd like to store the pointer to an array of strings, so that I can feed the module different arrays to display. I don't want to copy the array, just ...
John Peters's user avatar
  • 1,169
0 votes
1 answer
176 views

Can namespace functions be declared at block scope outside the namespace they were defined at? This code does not compile when DECLARED_IN_NS is defined as 1: #define DECLARED_IN_NS 1 // can be ...
digito_evo's user avatar
  • 3,735
1 vote
2 answers
97 views

For an assignment, I was given a header file. The objective was to write the function definitions in a C file. I am confused about how to write the definition for the functions when some of them do ...
Jarrod Boone's user avatar
1 vote
4 answers
131 views

hello i want to find a way to replace auto keyword in the following code. #include <iostream> using namespace std; void printMatrix(const auto & matrix) { /* print matrix using range-...
mahdi nemati's user avatar
1 vote
1 answer
55 views

Can anyone make sense of the difference in behaviour between the two snippets described below? Snippet #1 { function f() {return 1} f = function() {return 2} function f() {return 3} } ...
pdlaf's user avatar
  • 21
2 votes
1 answer
111 views

I am a beginner studying C++. Currently I am studying functions, C strings, and pass by reference. The program below is meant to take a string from input, replace any spaces with hyphens, and any ...
sam5855's user avatar
  • 33
0 votes
1 answer
73 views

Im trying to update a field of a struct that's a pointer like so: typedef struct Data *STRUCT_POINTER; typedef struct Data { int element; STRUCT_POINTER next; } STRUCT_NODE; void manipulate(...
Cloyd Abad's user avatar

1
2 3 4 5
10