Jump to content

Ler ficheiros em C


migmcc
 Share

Recommended Posts

Estou a fazer um programa que vai ler dum ficheiro legendas neste formato:

1

00:00:20,000 --> 00:00:24,400

In connection with a dramatic increase

in crime in certain neighbourhoods,

Não sei como consigo ler "00:00:20,000 --> 00:00:24,400" e coloca-las em em variáveis separadas para horas, minutos e segundos.

E para ler uma string de uma linha e passa-la para um vector?

Se houver alguém que me possa ajudar ficaria mesmo muito agradecido.

Fiquem bem

migmcc

Link to comment
Share on other sites

Porquê? Isso dá muito mais trabalho. Visto que já se sabe o tamanho e formato da string, usa a fscanf.

fscanf(handle_do_ficheiro, "%2d:%2d:%2d,%3d --> %2d:%2d:%2d,%3d", hInicio, mInicio, sInicio, msInicio, hFim, mFim, sFim, msFim);

Muito mais fácil e legível, imho.

❝The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.❞- John Carmack on software patents

A list  of command line apps

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.