• 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

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

static char inpbuf[MAXBUF], tokbuf[2 * MAXBUF],         *ptr = inpbuf, *tok = tokbuf; 

The array inpbuf is intended to store the user typed command and its arguments. The array tokbuf is intended to store each extracted tokens from inpbuf, such that, each element in the array char *arg[MAXARG + 1]; (in proc_line.c) is properly assigned using the information in tokbuf in order later on to invoke execvp system call in runcommand.c

I just want to get rid of tokbuf used in userin.c and make the program work can someone help me

userin.c

#include "smallsh.h"  static char inpbuf[MAXBUF], tokbuf[2 * MAXBUF], *ptr = inpbuf, *tok = tokbuf;  int inarg(char c);  int userin(char *p) {     int c, count;     ptr = inpbuf;     tok = tokbuf;          printf("%s", p);     count = 0;     while (1)     {         if ((c = getchar()) == EOF)             return(EOF);         if (count < MAXBUF)             inpbuf[count++] = c;         if (c == '
' && count < MAXBUF)         {             inpbuf[count] = '';             return count;         }                  if (c == '
')         {             printf("smallsh: input line too long
");             count = 0;             printf("%s ", p);         }     } }  int gettok(char **outptr) {     int type;          *outptr = tok;          while (*ptr == ' ' || *ptr == '	')         ptr++;          *tok++ = *ptr;          switch (*ptr++) {     case '
':         type = EOL;         break;     case '&':         type = AMPERSAND;         break;     case ';':         type = SEMICOLON;         break;     default:         type = ARG;                  while (inarg(*ptr))             *tok++ = *ptr++;     }     *tok++ = '';     return type; }  //**************************************************************************************** static char special[] = { ' ', '	', '&', ';', '
', '' }; int inarg(char c) {     char *wrk;     for (wrk = special; *wrk; wrk++)     {         if (c == *wrk)             return (0);     }     return (1); } 

runcommand.c

#include "smallsh.h" #include  #include   int runcommand(char **cline, int where) {     pid_t pid;     int status;     switch (pid = fork()) {         case 1:             perror("smallsh");             return (-1);         case 0:             execvp(cline[0], cline);             perror(*cline);             exit(1);     }     //code for parents     if (where == BACKGROUND)     {         printf("[process id %d]
", pid);         return (0);     }          if (waitpid(pid, &status, 0) == -1)         return (-1);     else         return (status); } 
Download script demo [LINK]
Download script demo [LINK 2] Download script demo [LINK 2]