hi to all
i've centos 6.6 and codeblocks 16.01. i want to build shared object library file. I chosed as
new->project->shared library, then language c then project title as "int_valid". now i gave following code in ( under project int_valid )
intvalidation.c
----------------
#include "intvalidation.h"
int intvalidation(const char * iint)
{
int i = 0, count = 0, len;
//unsigned long long int num = 0;
char * strnum = 0, chnum = 0;
strnum = (char *) malloc(sizeof (20));
//sprintf(strnum, "%d", iint);
len = strlen(iint);
printf(" len = %d ", len);
for( count = 0; count < len; count++)
{
chnum = (*(iint + count )) ;
i = chnum - 48;
if( i >= 0 && i <= 9 )
continue;
else
{
// printf("\n number is not valid \n");
return 0;
}
}
return 1;
}
in intvalidation.h
-------------------
#ifndef INTVALIDATION_H
#define INTVALIDATION_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int intvalidation(const char * iint);
#endif
in man.c file of second project :-
----------------------------------
#include <stdio.h>
#include <stdlib.h>
int intvalidation(char *iint);
int AddInt(int i1, int i2);
int main()
{
unsigned int x, y, sum = 0;
char *num1, *num2;
num1 = (char *)malloc(6);
printf("\n Enter number x = ");
scanf("%s", num1);
if(!intvalidation(num1))
{
printf("\n number %s is invalid \n", num1);
exit(1);
}
x = atoi(num1);
num2 = (char*) malloc(6);
printf( "\n Enter number to add: ");
scanf("%s", num2);
if(!intvalidation(num2))
{
printf("\n number %s is invalid \n", num2);
exit(1);
}
y = atoi(num2);
//sum = x + y;
sum = AddInt(x, y);
printf("\n %d + %d = %d", x, y, sum);
return 0;
}
in this project i want ot check validity of intger and making a shared library file for this
validation
now when i compile first project ( int_valid project having file file intvalidatoin.c and
intvalidatoin.h)
this generates sharedfile as :-
"liblibint_vaild.so"
why it is having two "lib" not a single one lib.
and second thing that how to link library file in our project.