migmcc Posted November 8, 2009 at 12:04 AM Report Share #295090 Posted November 8, 2009 at 12:04 AM 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 More sharing options...
Baderous Posted November 8, 2009 at 12:11 AM Report Share #295091 Posted November 8, 2009 at 12:11 AM Usa a função fgets para leres a linha do ficheiro para uma string e depois podes usar a função strtok para ires apanhando as diversas partes da string. Link to comment Share on other sites More sharing options...
IceBrain Posted November 8, 2009 at 02:21 AM Report Share #295106 Posted November 8, 2009 at 02:21 AM 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 More sharing options...
Baderous Posted November 8, 2009 at 12:24 PM Report Share #295124 Posted November 8, 2009 at 12:24 PM Também pode ser, é uma boa opção. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now