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

 

Diese Funktion akzeptiert die Anzahl der Terme in der Fibonacci-Folge im untergeordneten Prozess, erstellt ein Array und leitet die Ausgabe per Pipe an den übergeordneten Prozess um. Eltern müssen warten, bis das Kind die Fibonacci-Reihe entwickelt hat. Der empfangene Text zeigt immer -1 an, obwohl der gesendete Text die Anzahl der eingegebenen Zahlen *4 anzeigt, was akzeptabel ist.

 

 

#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<string.h>

int* fibo(int n)
{
    int* a=(int*)malloc(n*sizeof(int));
    *(a+0)=0;
    *(a+1)=1;
    int i;
    for(i=0;i<n-2;i++)
    {
        *(a+i+2)=*(a+i)+(*(a+i+1));
    }
    return a;
    }


    int main()
    {
        int* fib;
        int fd[2];
        pid_t childpid;
        int n,nb;

        int k=pipe(fd);
        if(k==-1)
        {
        printf("Pipe failed");
        return 0;
    }

    childpid=fork();
    if(childpid == 0) 
    {
        printf("Enter no. of fibonacci numbers");
        scanf("%d",&n);
        fib=fibo(n);
        close(fd[0]);
        nb=(fd[1],fib,n*sizeof(int));
        printf("Sent string: %d \n",nb);
        exit(0);
    }
    else
    {
        wait();
        close(fd[1]);
        nb= read(fd[0],fib,n*sizeof(int));
        printf("Received string: %d ",nb);
    }
    return 0;
}

 

vor 2 Stunden schrieb Jack.watts:

Diese Funktion akzeptiert die Anzahl der Terme in der Fibonacci-Folge im untergeordneten Prozess, erstellt ein Array und leitet die Ausgabe per Pipe an den übergeordneten Prozess um. Eltern müssen warten, bis das Kind die Fibonacci-Reihe entwickelt hat. Der empfangene Text zeigt immer -1 an, obwohl der gesendete Text die Anzahl der eingegebenen Zahlen *4 anzeigt, was akzeptabel ist.

Das find ich super!

  • Gast hat dies Thema gesperrt
Gast
Dieses Thema ist für weitere Antworten geschlossen.

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.