Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* coding with phyvar 20110220 */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main(int argc, char *argv[])
- {
- int i = atoi(argv[2]);
- int j = atoi(argv[1]);
- FILE *tiedosto;
- char tiedosto_nimi[10] = "mitta.dat";
- int d, k, testi = 0;
- char taulukko[i];
- struct taulu {
- char paiva[64];
- int arvo;
- };
- struct taulu mittaus[j];
- if ((tiedosto = fopen(tiedosto_nimi, "r")) == NULL) {
- printf("Tiedostoa ei löytynyt.");
- } else {
- for(d = 0; d < j; d++) {
- fgets(taulukko, i, tiedosto);
- strncpy(mittaus[d].paiva, taulukko, 63);
- fgets(taulukko, i, tiedosto);
- mittaus[d].arvo = atoi(taulukko);
- }
- }
- for (d = 0; d < i; d++) {
- if (mittaus[d].arvo >= 0 && mittaus[d].arvo <= i) {
- printf("%s ", mittaus[d].paiva);
- printf("%d\n", mittaus[d].arvo);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement