|
-
Nov 11th, 2005, 01:20 PM
#1
Thread Starter
Addicted Member
C on Cygwin using Gcc stat function {Resolved}
hello, excuse this work since im not that familiar with C but my university assignment says i must use it for this application.
I have to make a application to copy files with confirm overwrites i seem to have hit an issue
Im compiling this code using the Cygwin VM running on Windows XP compiling with GCC. can anyone see what is wrong with this code ?
Code:
#include <stdio.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
struct stat src_info;
struct stat dest_info;
int main(int argc, char **argv[])
{
//make sure we have a valid number of arguments
if (argc == 3)
{
printf("Source: %s\nDestination: %s\n", argv[1], argv[2]);
if (_stat(argv[1], &src_info) == -1) { printf("Error with source could not get i-node\n"); exit(0); }
if (_stat(*argv[2], &dest_info) == -1) { printf("Error with destination could not get i-node\n"); exit(0); }
}
}
i compile in Cygwin using...
$ gcc -o bin/safecp safecp.c
safecp.c: In function `main':
safecp.c:15: warning: passing arg 1 of `_stat' from incompatible pointer type
thank you for your help sam
Last edited by señorbadger; Nov 11th, 2005 at 02:50 PM.
Reason: {Resolved}
-
Nov 11th, 2005, 02:36 PM
#2
Re: C on Cygwin using Gcc stat function
Looks like you have a stray '*' before the filename the second time you call _stat. This will result in passing a character instead of a char*, which just could cause that warning.
Good luck!
Edit: in addition, your declaration for main is wrong, which is what is causing the problem in the first place:
try changing "char** argv[]" to "char* argv[]".
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Nov 11th, 2005, 02:48 PM
#3
Thread Starter
Addicted Member
Re: C on Cygwin using Gcc stat function
thank u, but my lecturer explained about the **argv today since its an array of strings. and he said the 2 stars are needed. will give it a shot
WoW it worked thanks !
ive decided i hate C C# all the way
-
Nov 11th, 2005, 05:09 PM
#4
Re: C on Cygwin using Gcc stat function {Resolved}
There are two legal ways of declaring argv: char **argv and char *argv[]. Maybe argv[][] is legal too, but I don't think so.
It's a bit early to hate C, don't you think?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 11th, 2005, 05:13 PM
#5
Thread Starter
Addicted Member
Re: C on Cygwin using Gcc stat function {Resolved}
yeah i guess had to do c last year at uni as well, but im so used to C#, java & php everything just takes 200 times longer.
I think all you people that work with C through choice deserve a heck of respect if i had a hat it would come off to a C / C++ developer, me I like cheap, dirty and fast
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|