一个初学C的人的困惑
cssin 2001-05-17 09:04:00 本人刚刚才开始学C,以前是用VB做开发的,发现从VB转C确实有些痛苦。这儿有一个C程序找不出错,希望大家帮忙看看(OS:RedHat 7.0)。
#include <stdio.h>
#include <math.h>
#include <string.h>
#define a 10
#define A 10
#define b 11
#define B 11
#define c 12
#define C 12
#define d 13
#define D 13
#define e 14
#define E 14
#define f 15
#define F 15
#define MAXSIZE 8
long int htoi(char s[])/* translate a hexadecimal value to its corrsponding decimal value */
{
int r;
int i = 0;
int len = strlen(s[]);
for (i = 0; i < len; i++)
r = r + s[i] * pow(10,len - i - 1);
return r;
}
main()
{
printf("Please input a hexadecimal digits(no longer than 8):");
scanf("%s",&hex);
htoi(hex);
}