assignment makes pointer from integer: but why?

hi all
when i compile the following program i get a compiler warning, but i don't understand why. for me the code seems to be all right and does legitimate this warning. so here is the code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// multiplication.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "crypto.h"

#define PROGNAME "multiplication"

void usage();
int isnumaber(char* str);

int main(int argc, char** argv)
{
  if(argc != 4)
    usage();
  if(!isnumber(argv[2]))
    usage();

  char* buffer;
  unsigned int key = atoi(argv[2]);
  if(key <= 0)
    usage();
  if(argv[1][0] == 'e')
    buffer = multiplication_encrypt(key, argv[3]);
  else if(argv[1][0] == 'd')
    buffer = multiplication_decrypt(key, argv[3]); //the line the gcc complains about
  else
    usage();
  if(buffer == NULL)
    usage();
  printf("%s\n", buffer);
  free(buffer);
  return 0;
}
...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// crypto.h
#ifndef CRYPTO_H
#define CRYPTO_H

#include <stdint.h>
typedef uint16_t bigram_t;
struct letter_occurence { char letter; int occurence; };
struct bigram_occurence { bigram_t bigram; int occurence; };

extern const char alphabet[2][26];

char* loadfile(char* path);
char* caesar_encrypt(int key, const char* str);
char* caesar_decrypt(int key, const char* str);
char* multiplication_encrypt(unsigned int key, const char* str);
char* multiplicarion_decrypt(unsigned int key, const char* str); // the function called in this line 
char* affine_encrypt(unsigned int key1, unsigned int key2, const char* str);
char* affine_decrypt(unsigned int key1, unsigned int key2, const char* str);
int alphabet_index(char c);
int modulo(int a, int b);
struct letter_occurence* count_letters(const char* str);
struct bigram_occurence* count_bigrams(const char* str);

#endif 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//crypto.c
...

char* multiplication_decrypt(unsigned int key, const char* str)
{
  if(key%2 == 0 || key%13 == 0)
    return NULL;
  int len = strlen(str);
  char* plain_txt = (char*) malloc(len);
  memset(plain_txt, 0, len);
  // find factor to decrypt [ (factor*key)%26 = 1 ]                                                                   
  int factor = 0;
  register int i;
  for(i=1; factor==0; i++) { // infinite loop possible???                                                             
    if((26*i+1)%key == 0)
      factor = (26*i+1)/key;
  }
  // decrypt and return                                                                                               
  register int j = 0;
  for(i=0; i<len; i++) {
    if(isalpha(str[i]) != 0) {
      plain_txt[j] = alphabet[0][(alphabet_index(str[i])*factor)%26];
      j++;
    }
  }
  return plain_txt;
}

...

compiled with:
1
2
3
4
5
6
$ gcc -o multiplication multiplication.c crypto.c
multiplication.c: In function 'main':
multiplication.c:26:12: warning: assignment makes pointer from integer without a cast [enabled by default]
     buffer = multiplication_decrypt(key, argv[3]);
            ^
$


any ideas where this warning comes from?
thank you for helping me,
ritka
Compile with warnings
$ gcc -c -W{all,extra} multiplication.c
multiplication.c: In function ‘main’:
multiplication.c:16:3: warning: implicit declaration of function ‘isnumber’ [-Wimplicit-function-declaration]
multiplication.c:26:5: warning: implicit declaration of function ‘multiplication_decrypt’ [-Wimplicit-function-declaration]
multiplication.c:26:12: warning: assignment makes pointer from integer without a cast [enabled by default]


Now if you see your header, you wrote `multiplicarion_decrypt'
Also note that you have declared `isnumaber'
oh f*ck, what a silly mistake :D. sry for bothering you with this. but thx
Topic archived. No new replies allowed.