Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo..

ich bin C-Neuling...

Ich habe in einem Ordner z.B. C:\Temp, Dateien der Form line1.dat, line2.dat etc... und möchte das mir eine Funktion die Anzahl dieser zurückgibt...

Wer kann mir sagen wie das geht (mit einem kurzen Bsp.-programm)

... DANKE

Hallo Frank...

Danke erstmal für die schnelle AW, aber ich benötige ein C-Programm/funktion, die das macht ...nicht C++

C Tutorial

was sagst du dazu...

leider blicke ich nicht durch...

bräucht mal auf mein Bsp. zugeschnittenes Programm, einfach Anzahl der Dateien in der form line1.dat, line2.dat soll mir zurückgegeben werden...

<danke

Danke erstmal für die schnelle AW, aber ich benötige ein C-Programm/funktion, die das macht ...nicht C++

Nur weil C++ im Titel steht bedeutet es nicht, dass die Beispiele mit mehr oder weniger Aufwand auch unter C laufen würden.

C Tutorial

was sagst du dazu...

leider blicke ich nicht durch...

Was ist an dem Beispiel nicht zu verstehen?

bräucht mal auf mein Bsp. zugeschnittenes Programm, einfach Anzahl der Dateien in der form line1.dat, line2.dat soll mir zurückgegeben werden...

Eine fertige Funktion ist mir nicht bekannt. Da muss man schon selber basteln.

Frank

Hallo, habs jetzt mal probiert, iwie meckert der Compiler bei pfad=str rum?

#include <stdio.h>

#include <stdlib.h>

#include <windows.h>

int ausl_verz()

{

FILE *datei; // Deklaration

int a,counter=0;

char str[100], pfad[100], nr[5], datend[5]={".dat"};

printf("Bitte geben Sie den Pfadnamen ein:");

scanf("%s",&str);

for(a=1;a<=100;a++)

{

pfad=str;

sprintf(nr, "%d",a); //Pfadnamen "zusammenbasteln"

strcat(pfad,nr);

strcat(pfad,datend);

datei = fopen(pfad, "r"); //Datei öffnen

if(datei != NULL)

{counter++;

}

fclose(datei); //Datei schließen

}

return counter;

}

int main(int argc, char *argv[])

{

int counter;

counter=ausl_verz();

printf("anzahl daten=%i",counter);

getchar();

return 0;

}

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.