[prev in list] [next in list] [prev in thread] [next in thread] 

List:       suse-programming-e
Subject:    [suse-programming-e] looping through **environ?
From:       "Steven T. Hatton" <hattons () globalsymmetry ! com>
Date:       2003-03-25 8:58:58
[Download RAW message or body]

Someone provided me this sample code getting the **environ variable from the 
system and displaying it.  It doesn't seem to work correctly.  the body of 
the for-loop executes four times.  I believe there is far more data available 
than that.  Am I correct in that assumption?  If so, why is this code not 
getting it all.  It's been ages since I wrote any C/C++, and I was never 
fluent in these languages.  I recall that working with pointers can be 
tricky.  By the example on 58 of Ellis & Stroustrup I am lead to believe the 
code below should work.  Any suggestions?

#include <qapplication.h>
#include <qlabel.h>
#include "text_display.h"

extern char **environ;

unsigned int i;
QObject *label;
QString environString = "This is the process environment.\n";

int main( int argc, char ** argv )
{
    QApplication a( argc, argv );
    textDisplayWidget *w = new textDisplayWidget;
    label = w->child("TextLabel");
    for(i=0; i<(sizeof(environ)); i++)
    {
        environString.append("(QString)environ[i]");
        environString.append("\n");
    }
		((QLabel*)label)->setText(environString);
    w->show();
    a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    return a.exec();
}

-- 
To unsubscribe, email: suse-programming-e-unsubscribe@suse.com
For additional commands, email: suse-programming-e-help@suse.com
Archives can be found at: http://lists/archive/suse-programming-e

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic