copy web informations in C [closed] - c

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm new to C so please explain your answers as much as you can :)
What i would like to do is this:
i want to create in C a program that goes to a specific site and copies certain data to a txt file from where i can analyze them.
The question is how i copy these informations?
is this something that can be done in C?(if yes tell me the library that i have to use or the code)
for example i want to make my program do this:
go to this site - copy the lines(1-10)
thanx for your help

Simply use curl link to the webpage -o file or wget link to page in your program with system(),
But by default you will get HTML source of page. From that you can copy your required info.
if your link is a text file like this
Then it will fetches as it is. Then you can open that file with fopen().read first ten lines with fgets(). copy into another file.
you can also use libcurl library

Related

How to get input from user via command line while bison/flex reads file? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 days ago.
Improve this question
I'm new to flex and bison and i couldn't figure it out. I want to read a file. This is okey for now. But while bison/flex parse and read file, I want to make it wait for new input and get it from command line. Is there a keyword or way to do it?
I tried abort yyparse() with yyerror() and get input by scanf(). But it didn't work. It doesn't wait for input and goes on.
I did a project school named mini_shell and what we asked to do was to code something like bash.
the main thing was to wait for user input and execute the command he entered, you can do that by a function named.
char *readline(const char *prompt); (you can read the man page to understand more https://man7.org/linux/man-pages/man3/readline.3.html) but I think you need to install it first before you can use it, you can find a lot of tutorials explaining how to do that based on your OS.

How to get the last n files in a directory [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I need help with getting the last 3 files in a directory.
I have an application that creates files in it and they have dates in the file names displayed as MMDD eg 0301.
There are a few files that have differents names but all have the dates on them and I'm new to C programming and don't know how to display only the last 3 file names.
If someone could help me it would be really appreciated.
Thank you
The typical and most robust way would be:
Read the contents of the directory into an in-memory array (see opendir() and friends if you're on POSIX)
Sort the array based on the filenames (using qsort() of course)
Extract the three last elements
Of course this would be brittle if files can be created while you're doing this, that is typical for this kind of filesystem-inspection.

How to write bytes to disc in C? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I want to write a program that formats a disc to a new format (not NTFS or FAT32) and can read from and write to the disc, In order to do this, I have to have a way to write single bytes to a disc (without creating files). How do I do that?
EDIT: I found this. But I'm not sure if using CreateFile() as Eli Bendersky said in the first answer (when organized in order of votes) let's you write one byte (or even one bit) at a time, or do you have to write full sectors at a time.
Answer: Since I can't post an answer the question because it was closed, I will answer it write here. You don't need need API functions to do this. All you need to do is open the disk like you open any other file. Like this:
int hFile;
hFile=open("/dev/sdb",0_RDWR);
You program has to directly talk to the driver as you will be by-passing the file-system.

Reading Linux via Windows [C program] [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
My teacher asked my class to make a c program to read data on my linux partition via a c program in windows .
As such , after a good amount of research , i have been unsuccessful to find even the smallest hint as to how .
I realize the eof is different , but changing that allows me to read a file created in linux , not directly access the linux partition itself .
I was hoping that someone could please gimme a clue .
P.S I would really appreciate it if i was not given the complete code / info , i just wanna know where to start .
Can you read a "windows" file on "windows"? This is a good starting point along with manual pages for fopen etc.
EOF is the same everywhere - it is the end of file. The library "stdio" treats it the same wherever. That is why it is called standard IO
Just mount the linux partition onto your windows machine. I think the lecturer was doing this to make sure you was awake during the course.

how to print a flat file list windows [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I thought this would be easy to do, but I can't wrap my head arond it.
I need to print a report of all the files in a dir, including sub dirs on a windows server.
Folder01\File01.txt
Folder01\File02.txt
Folder02\File01.txt
etc
Is there an easy way to spit that out to the screen?
Obviously i would pipe to file eventually, but I am still trying to figure out how to get a flat file list of a windows hierarchy printed out
You didn't give a language. There are many options. The simplest is probably dir/b/s in the Windows shell.

Resources