Help needed compiling C code

From: JS (dsa._at_asdf.com)
Date: 11/18/04


Date: Thu, 18 Nov 2004 23:52:23 +0100

I have this code:

#include <stdio.h>

void strcpy (char x[], char y[])
{
    int i;

    i = 0;
    while ((x[i] = y[i] != '\0')
    i +=1;
}

int main(int argc, char *argv[])
{
char p;
p = strcpy("aasdf","sdgd");
printf("%d\n",p);
fgetc(stdin);
return 0;
}

But when I compile it I get the following errors:

Compiler: Default compiler
Executing g++.exe...
g++.exe "E:\Datalogi\C kode\Untitled2.cpp" -o "E:\Datalogi\C
kode\Untitled2.exe" -g3 -I"C:\Programmer\Dev-Cpp\include\c++\3.3.1" -I"C
:\Programmer\Dev-Cpp\include\c++\3.3.1\mingw32" -I"C:\Programmer\Dev-Cpp\in
clude\c++\3.3.1\backward" -I"C:\Programmer\Dev-Cpp\lib\gcc-lib\mingw32\3.3.
1\include" -I"C:\Programmer\Dev-Cpp\include" -L"C:\Programmer\Dev-Cpp\lib
" -g3
E:/Datalogi/C kode/Untitled2.cpp: In function `void strcpy(char*, char*)':
E:/Datalogi/C kode/Untitled2.cpp:9: error: syntax error before `+=' token

E:/Datalogi/C kode/Untitled2.cpp: In function `int main(int, char**)':
E:/Datalogi/C kode/Untitled2.cpp:16: error: void value not ignored as it
ought
   to be

Execution terminated

Can someone help me correcting it?

js



Relevant Pages

  • Re: How to use a C++ class in .NET
    ... > absolutely compiler dependant. ... > public ref class MyClass ... > int funtion1(unsigned char* inBuffer, unsigned inType, unsigned char* ...
    (microsoft.public.dotnet.framework)
  • Re: int or long int?
    ... case it was left up to the compiler to choose what to define the var ... were trying to place in there was larger than a 16 bit int could hold. ... and whats wrong with correcting poor coding, ... How do you know you're "correcting" it? ...
    (comp.programming)
  • Re: How to use a C++ class in .NET
    ... absolutely compiler dependant. ... public ref class MyClass ... int funtion1(unsigned char* inBuffer, unsigned inType, unsigned char* ...
    (microsoft.public.dotnet.framework)
  • Re: querry related to structure padding
    ... char B; ... The compiler is still free to insert padding between B and C, ...
    (comp.lang.c)
  • Re: Error in Passing char pointer
    ... int main ... Always ensure that the compiler sees a prototype for each function before calling it. ... Why is ea unsigned char when everything else is signed char? ... Also your pointer types disagree with the pointers you are passing, unsigned char* and char* are not the same. ...
    (comp.lang.c)