1. ## Help with Functions

i have tried the same code without using functions ... and it worked perfectly ...

but now when i try to use Funztions for the same programme ... it doesnt works for me ....

i thnk there is a problem with CHAR in functions .... can some can help me ??

2. Moved to C++ programming forum. Also, the code attached is:
Code:
```/*
Name: Haider Ali
Date: 16/09/12 18:08
Description: Conversione da Binario ad Intero ; Riceve un array come parametro e restituisce il numero decimale
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
#include <math.h>

int deciimale(char parola[]);

int main () {
char word[20];
int deci;

//Inserimento del numero binario in una Stringa Caratteri per poi calcolare la lunghezza con strlen
cout<<"Insert a Binary Number :  ";
cin>>word;

deci=deciimale(word[]);

printf("\n\n\n");
cout<<"The Decimal Number for your Binary Number is :   " <<deci;

//system("pause");
getch();

}

int deciimale (char parola[]){
int decini;
int dectot=0;
int l;
int par[20];
int j;
int i;

l=strlen(parola);
/*conversione della stringa dal Char in INT con i valori corrispondenti al codice ASCII
for (i=0;i<l;i++)
par[i]= (int)parola[i];*/
//facendo -48 si ottiene il valore 1 o 0 nel codice ASCII
for (i=0;i<l;i++)
par[i]= parola[i]-48;

//Conversione del numero binario in Decimale
j=l-1;
for (i=0;i<l;i++) {
decini = par[j]* pow(2,i);
j--;
dectot = dectot + decini;
}

return dectot;
}```

3. Now, I think you need to be clear that these include C standard headers:
Code:
```#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>```
The C++ equivalents are:
Code:
```#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>```
Unless you have special reason to use C standard I/O, you should stick with C++ standard I/O, hence you should not #include <cstdio>. Next, this includes a pre-standard header:
Code:
`#include <iostream.h>`
The correct standard header should be included by:
Code:
`#include <iostream>`
Code:
`#include <conio.h>`
You are using it for getch, but you don't need getch to begin with: run your command line program from a command prompt window.

Now, in your main function, you attempt to make a function call:
Code:
`deci=deciimale(word[]);`
However, to pass word as an argument, it should be:
Code:
`deci = deciimale(word);`

4. sorry the comments are all written in Italian ... i forgot to translate into English ...

the programme is for Converting Binary Numbers into Decimal numbers ...

if there something somebody doesnt understand ... i can help to translate it

5. i use all those libraries just because im at start with these things ... and i write all the libraries i know ....

does the C++ libraries worked perfectly also with the C language ?

6. Originally Posted by haiderali
does the C++ libraries worked perfectly also with the C language ?
Your program is a C++ program, or is it not?