How can I pass array to function argument?

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 element) { int mainArr[10] = {0, 2, 1000, 6, 9, 11, 43, 8, 123, 87}; mainArr[index] = element; for (int i = 0; i < 10; i++) { printf("%d\n",… Read More How can I pass array to function argument?

struct node * void expected identifier or '(' before 'void'

There is a function like this. I took this error expected identifier or ‘(‘ before ‘void’ How to solve this problem? Thank you. struct node * void ekleSirali(struct node * r,int x){ if(r==NULL){ r=(struct node *)malloc(sizeof(struct node)); r->next=NULL; r->x =x; return r; } I don’t know whether I should write struct. >Solution : The type… Read More struct node * void expected identifier or '(' before 'void'

Why does a function in C(or Objective C) with no listed arguments allow inputting one argument?

In C when a function is declared like void main(); trying to input an argument to it(as the first and the only argument) doesn’t cause a compilation error and in order to prevent it, function can be declared like void main(void);. By the way, I think this also applies to Objective C and not to… Read More Why does a function in C(or Objective C) with no listed arguments allow inputting one argument?

Why do I get "forbids converting a string constant to ‘char*’" in C++?

I’m trying to invert the case manually, and I tried this: char* invertirCase(char* str){ int size = 0; char* iterador = str; char* retorno = str; while (*iterador != ‘\0’) { if (retorno[size] < 96) { retorno[size] = *iterador + 32; } else { retorno[size] = *iterador – 32; } iterador++; size++; } return retorno;… Read More Why do I get "forbids converting a string constant to ‘char*’" in C++?

Integer literal as parameters of function declaration in cpp

I’m almost familiar with c and c++ programming. Today I was searching about function declaration when I suddenly came across a strange syntax in c++ language. I wrote below code: #include <iostream> using namespace std; int foo(‘3′); int bar(3); int main(){ } I’ve never seen defining the literals as function parameters! So I expected to… Read More Integer literal as parameters of function declaration in cpp