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.

Brauche Hilfe mit ASCII C

Empfohlene Antworten

Veröffentlicht

Moin, Moin

ich habe vor ein paar Tagen begonnen ASCII C zu lernen. Ich komme aber

irgendwie nicht weiter.

Das Program solle eine Datei einlesen und soll prüfen ob der angegebene String in der Textdatei zu finden ist.


#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#define MAX 20


int main()


char eingabe[20];


{


FILE *file;

file = fopen("frank.txt", "r");

    if(NULL == file) {

    printf("Datei \"index.txt\" nicht gefunden!\n");

    return EXIT_FAILURE;



printf ("Bitte geben das Suchwort an: ");

fgets(eingabe, MAX, stdin);


if (strstr(file, eingabe))


puts ("String gefunden\n");


else


puts ("String nicht gefunden\n");

}

Bekomme folgende Fehlermeldung:

suchen.c: In Funktion main:

suchen.c:9: Fehler: Deklaration für nicht vorhandenen Parameter eingabe

suchen.c:23: Warnung: Übergabe des Arguments 1 von strstr von inkompatiblem Zeigertyp

suchen.c:30: Fehler: expected declaration or statement at end of input

Kann mir jemand sagen was ich da falsch gemacht habe und einen Schub

in die richtige Richtung geben.

Vielen Dank

- char eingabe[20] kommt nach der geschweiften Klammer.

- nach return EXIT_FAILURE fehlt }

- strstr kannst du nicht einfach den Filepointer als Parameter übergeben. Du mußt zuerst den Inhalt der Datei einlesen

P.S.: Was ist eigentlich ASCII C? Ich kenn nur ANSI C

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.