When trying to compile a C program including the code below, I keep getting this error and I don't know what to do to fix it. Please explain if you can!
Complete code may be downloaded from my website at www.atrixnet.com/cquestion.zip (It's only 2 Kb)
I suppose I'll attach it to this post too, since that appears to be an available feature on this board :)
COMPILATION ATTEMPT:
tommy@city-it ~/cdevel
$ gcc -Wall -ansi -pedantic -mno-cygwin -I . -o myfirstlib myfirstlib.c
ERROR:
myfirstlib.c: In function `main':
myfirstlib.c:14: warning: passing arg 2 of `strcpy' makes pointer from integer without a cast
myfirstlib.c:20: warning: passing arg 2 of `strcpy' makes pointer from integer without a cast
CODE SUMMARY (main program):
#include <stdio.h>
#include <string.h>
#include <myfuncs.h>
int anumber;
char astring[255];
int
main ()
{
printf ("This is the first time I've tried to '#include' my library!\n\n");
anumber = getnum("Enter some kind of integer: ");
strcpy(astring, getstring("Enter your name: "));
printf("\nThank you, %s. You entered %d\n", astring, anumber);
while (getyn("\nDo you want to go again? [Y/n]")) {
anumber = getnum("Enter some kind of integer: ");
strcpy(astring, getstring("Enter your name: "));
printf("\nThank you, %s. You entered %d\n", astring, anumber);
}
printf("\nBye.\n");
return (0);
}
CODE SUMMARY (from myfuncs.h):
/* will act as the buffer into which user's response will be stored */
char lineofinput[255];
/* grabs a string from the command prompt */
char
getstring (char strquestion[255])
{
/* reset */
char lineofinput[255];
if (strlen (strquestion))
printf ("%s", strquestion);
fgets (lineofinput, sizeof (lineofinput), stdin);
/* while we get an empty response */
while (strlen (lineofinput) == 1)
{
if (strlen (strquestion) == 1)
printf ("Empty answers not permitted. Please try again: ");
return (getstring (lineofinput));
}
return (sprintf("%s", lineofinput));
}
MY COMPILER:
tommy@city-it ~/cdevel
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/specs
Configured with: /gcc/gcc-3.3.3-3/configure --verbose --prefix=/usr --exec-prefi
x=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,java,objc,
pascal --enable-nls --without-included-gettext --enable-libgcj --with-system-zlib --enable-interpreter --enable-threads=posix --enable-java-gc=boehm --enable-sjlj-exceptions --disable-version-specific-runtime-libs --disable-win32-registry
Thread model: posix
gcc version 3.3.3 (cygwin special)