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.

C --- "popen()"

Empfohlene Antworten

Veröffentlicht

hallo leutens,

kann mir jemand mal ein anwendungsbeispiel für popen() hier reinpasten?

ich muß aus einem c proggie heraus ein ls machen und will die dateien, die normalerweise in der konsole angezeigt werden, in einem string speichern ...

danke !!

wink.gif

poldi

Hi

Das hier ist aus Visual C++

vielleicht hilft dir ja das weiter

dein Hasi

/* POPEN.C: This program uses _popen and _pclose to receive a

* stream of text from a system process.

*/

#include <stdio.h>

#include <stdlib.h>

void main( void )

{

char psBuffer[128];

FILE *chkdsk;

/* Run DIR so that it writes its output to a pipe. Open this

* pipe with read text attribute so that we can read it

* like a text file.

*/

if( (chkdsk = _popen( "dir *.c /on /p", "rt" )) == NULL )

exit( 1 );

/* Read pipe until end of file. End of file indicates that

* CHKDSK closed its standard out (probably meaning it

* terminated).

*/

while( !feof( chkdsk ) )

{

if( fgets( psBuffer, 128, chkdsk ) != NULL )

printf( psBuffer );

}

/* Close pipe and print return value of CHKDSK. */

printf( "\nProcess returned %d\n", _pclose( chkdsk ) );

}

Output

Volume in drive C is CDRIVE

Volume Serial Number is 0E17-1702

Directory of C:\dolphin\crt\code\pcode

05/02/94 01:05a 805 perror.c

05/02/94 01:05a 2,149 pipe.c

05/02/94 01:05a 882 popen.c

05/02/94 01:05a 206 pow.c

05/02/94 01:05a 1,514 printf.c

05/02/94 01:05a 454 putc.c

05/02/94 01:05a 162 puts.c

05/02/94 01:05a 654 putw.c

8 File(s) 6,826 bytes

86,597,632 bytes free

Process returned 0

Super, danke dir!!

Damit kann ich schon mehr anfangen ... ;o)

cu

Poldi

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.