Anonymous
Source code: /* cp command simulation - copy.c */ #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <sys/stat.h> #define SIZE 1024 int main(int argc, char *argv[]){ int src, dst, nread; char buf[SIZE]; if (argc != 3){ printf("Usage: gcc copy.c -o copy\n"); printf("Usage: ./copy <filename> <newfile> \n"); exit(-1); } if ((src = open(argv[1], O_RDONLY)) == -1) { perror(argv[1]); exit(-1); } if ((dst = creat(argv[2], 0644)) == -1){ perror(argv[1]); exit(-1); } while ((nread = read(src, buf, SIZE)) > 0){ if (write(dst, buf, nread) == -1){ printf("can't write\n"); exit(-1); } } close(src); close(dst); return 1; }
Anonymous
nvm, I found it, looks like read(), write() declarations are in #include <unistd.h> But I wonder How it worked for the gcc MINGW in my windows
Богдан
This maybe help u "main.c: In function ‘main’: main.c:25:18: warning: implicit declaration of function ‘read’; did you mean ‘fread’? [-Wimplicit-function-declaration] 25 | while ((nread = read(src, buf, SIZE)) > 0){ | ^~~~ | fread main.c:26:9: warning: implicit declaration of function ‘write’; did you mean ‘fwrite’? [-Wimplicit-function-declaration] 26 | if (write(dst, buf, nread) == -1){ | ^ | fwrite main.c:31:2: warning: implicit declaration of function ‘close’; did you mean ‘pclose’? [-Wimplicit-function-declaration] 31 | close(src); | ^ | pclose"
Anonymous
/get
MAC
Lol
armandofsanchez
So its pointing to the next position
armandofsanchez
Of memory
Gulshan
https://del.dog/egrestarod.txt
Gulshan
Gulshan
what should be done ?
Nils
Time limit exceeded
Increase integer bitnes
Vlad
Increase integer bitnes
Would've been funny with a comma
Gulshan
Increase integer bitnes
I didn't get you
Nils
https://del.dog/egrestarod.txt
Why do you #define endl to '\n'?
Gulshan
Why do you #define endl to '\n'?
@oli one said this to me to use it
Ishank
Hlo i need some likes on insta photo , can i send here?
Gulshan
but this actually reduces some time
Nils
Send in PM instead, or #off-topic at least
a Semicolon
Nils
Send in PM instead, or #off-topic at least
No not to me, to the one who asked
Serhat
hi, how can i store integers without using array?
Ammar
hi, how can i store integers without using array?
Struct should be capable. struct my_ints { int a; int b; int c; };
Serhat
Struct should be capable. struct my_ints { int a; int b; int c; };
what if i dont know how many number user is gonna enter?
Serhat
C++?
C :(
Ammar
Prince Of Persia
C :(
Use pointers with malloc()
Ammar
Without array, you can use linked list anyway.
Serhat
You need dynamic allocation for that.
i know but thats not allowed :(
Ammar
i know but thats not allowed :(
Could you show the full instruction?
Serhat
Jomac d Learner
Please i need a good c++ programmer to inbox me for a project Thanks
Ahadu
Nameful
grew hat hacker
Ahadu
grew hat hacker
They are hackers sometimes like white hat hacker sometimes Black hat hackers
AS🌸
Could any one help with this https://github.com/AndyNovo/speedruns/commit/fa54d698b7bb5cee0d133b63d9495541860c0d28#diff-914798cf605097c01d7649b09273a50d142cc7c26abf76054f727a7d596571f5
Ahadu
How many hackers are there
Diego
How many hackers are there
at least 3 I'd say
Dima
lmao what the hell
Anonymous
69
Юрій
There are two types, white and those who were caught)
AmR
Any one know where I can find src for file command ?
Ammar
What's the deal in comparing malloc and bzero? They both serve different purpose.
Vlad
Lol they function differently
Nomid Íkorni-Sciurus
I'm new to this. What is bzero?
Vlad
"cup or the pencil"
Ammar
I'm new to this. What is bzero?
It's like memset(ptr, 0, size).
MAC
Nomid Íkorni-Sciurus
Ammar
Still stupid comparison.
Nomid Íkorni-Sciurus
It's like memset(ptr, 0, size).
Ah I see. They're different in function though :/
Vlad
Okay, why memcpy tho?
Nomid Íkorni-Sciurus
why memcpy?
Vlad
memset exists for that
Vlad
Nomid Íkorni-Sciurus
yeah
MAC
I use t9
MAC
Vlad
Why don't?
It copies from one memory location to the other. It doesn't fill memory uniformly
MAC
memset exists for that
It's old question , there are lot of different opinions
Vlad
So you'd need an array of exact size full of zeros to zero fill this one
Vlad
Which just defies the purpose
MAC
What opinions lol?
Why I can't put 0 with memcpy ?
Vlad
Why I can't put 0 with memcpy ?
As I told already it copies from one memory location to the other
Vlad
And it must be the same size or more
Ammar
It's old question , there are lot of different opinions
It's objectively bad choice to zero memory with memcpy. Unless the condition meets your need.
Vlad
Why does it copy ?
Cause it's memcpy -> memcopy
Vlad
Lmao