abhimanipal 91 Master Poster

Well suppose after the first sort, this is your input array

int arr[10]={1,2,3,7,8};

if the user enters 6, all you got to do is move the elements 8,7 one step behind. You see 8 is greater than 6 copy 8 to the 6th location. Same applies for 7. 3 is not greater than 6, so the loop ends there

abhimanipal 91 Master Poster

Your array size is 5 and you want to continuously read the user input till the user exits, how will there be sufficient space in the array ?

abhimanipal 91 Master Poster

Will your input always be a square matrix ? Or the way you are calculating the number of columns is wrong.

Read a line using fgets, then copy that line character by character at the appropriate location in the matrix.

abhimanipal 91 Master Poster

Right

abhimanipal 91 Master Poster

Can you post the output that you are getting. This is the output that I am getting when I run your code

timberlake {~} > ./test1
9 9 1 1 1 8 8 8 8 2 2 7 7 3 3 3 4196247 9 9 8

timberlake {~} >

The last 4 values are junk. But the main point is I think no values from array B have been skipped

abhimanipal 91 Master Poster

I want to see your print function . If it is some thing of this sort

for(i=0;i<20;i++)
                printf("%d\n",arr3[i]);

Then you will get junk characters in the ending. The reason for this is that there are less than 20 numbers in arr 3.

abhimanipal 91 Master Poster
while(line[k] != '\0')
        {
                argv[i] = (char *)malloc(sizeof(char) * 11);

/*
   while(line[k] != ' ')
   This should be 
          while(line[k]!= ' '&& line[k]!='\0')
   If you give the command of the type "/bin/ls , your loop keeps on 
   searching till it find the space character
*/

                {
                  argv[i][j] = line[k];
                                k ++;
                                j ++;
                }
	      argv[i][j] = '\0';
                        j = 0;
                        k ++;
                        i ++;
        }
        execve(argv[0], argv, envp);
        return 0;
}

Also why are you using the argv array to store the parameters. Why not make a separate array ?

abhimanipal 91 Master Poster

I am not SURE.... but it is very unlikely...

abhimanipal 91 Master Poster

Well from WHAT I KNOW, most modern operating systems do not use SJFS.
SJFS is more common in the batch computing days when the user had to explicitly submit his jobs. In such a scenario when the user submitted his job he was required to estimate the run time also
Most of the current operating systems use prioritized round robin scheme. In this all processes start at the same priority. Then if the process used the entire time slot and does not finish, it is assumed that this is a batch job and the priority of this process decreases. Similarly if the process uses a part of it allotted time and then tell the OS that it needs IO, the process is assumed to be interactive and its priority is increased.

abhimanipal 91 Master Poster

Quick question , how are you making stars, archers, hearts appear on the screen ?

abhimanipal 91 Master Poster
int check_mat (int mat[N][M], int i, int j)
{
	int r,c;
	int flag = 1;

	for(r=i-1; r<i+1 ; r++)
	{
		for(c=j-1; c<j+1 ; j++)
			
				if(mat[i][j]>mat[r][c]&&IsInside(r,c))
								return 1;
						   			return 0;

	}
	
}

The for loop should be

for(r=i-1; r<=i+1 ; r++)
		for(c=j-1; c<=j+1 ; j++)

Otherwise you will miss the last row/columns

abhimanipal 91 Master Poster

Quick question can you do something of this sort ? Will help you to simplify the code ?

void calc()
{
      // Check which operation is to be done
      // Then call the appropriate function
}

Check this link for more information on function pointers
http://www.cprogramming.com/tutorial/function-pointers.html

abhimanipal 91 Master Poster

Another option could be to use command line arguments

int main(int argc, char* argv[])
{
      // The values can be retrieved from argv. These values can be int, float, string. 
}