• 0

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /var/www/html/cnasolution/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/index.php
Line: 315
Function: require_once

I have this code:

int main(void){    printf("Type something:
");   while(1){     char * array = NULL;     size_t size = 0;          getline(&array, &size, stdin);      if( (strlen(array) == 0) && feof(stdin) ){       free(array);       return 0;     };          /* do something else */     free(array);   }    return 0; } 

I want to end my program, when the first thing comes from input is EOF, but valgrind shows Conditional jump or move depends on uninitialised value(s). I know the problem must be strlen(array), but do not know, how to do it a different way. I can do:

if(feof(stdin)){   free(array);   return 0; } 

but, if someone type a string and then end it with EOF, my program would stop too and I don't want that (because I need to do something else with that string). Any suggestion please? I am a beginner at C language.

Download script demo [LINK]
Download script demo [LINK 2] Download script demo [LINK 2]