How to use execvp() to execute a command

The prototype of execvp is It expects a pointer to char as the first argument, and a NULL-terminated pointer to an array of char*. You are passing completely wrong arguments. You are passing a single char as first argument and a char* as the second. Use execlp instead: So Also the convention in UNIX is to print error messages to stderr and a process with an error should have … Read more

How to use execvp()

The first argument is the file you wish to execute, and the second argument is an array of null-terminated strings that represent the appropriate arguments to the file as specified in the man page. For example:

Implementing Taylor Series for sine and cosine in C

Anything over 12! is larger than can fit into a 32-bit int, so such values will overflow and therefore won’t return what you expect. Instead of computing the full factorial each time, take a look at each term in the sequence relative to the previous one. For any given term, the next one is -((x*x)/(flag_2*(flag_2-1)) times the previous one. So … Read more

How many spaces for tab character(\t)?

A tab character should advance to the next tab stop. Historically tab stops were every 8th character, although smaller values are in common use today and most editors can be configured. I would expect your output to look like the following: The algorithm is to start a column count at zero, then increment it for … Read more

What is a segmentation fault?

Segmentation fault is a specific kind of error caused by accessing memory that “does not belong to you.” It’s a helper mechanism that keeps you from corrupting the memory and introducing hard-to-debug memory bugs. Whenever you get a segfault you know you are doing something wrong with memory – accessing a variable that has already … Read more