Writing beyond that is rampaging through stack space, overwriting every local variable behind it until it finds and corrupts your stack frame itself, crashing your program the next time it tries to do anything to the stack.
Code:
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
int i;
char theCommand[16384] = "cat ";
for (i = 1; i < argc; i++)
{
strcat(theCommand, argv[i]);
}
strcat(theCommand, " >> testfile.txt");
system(theCommand);
return 0;
}
D'oh! That would explain the segmentation fault, then.
Thank you very much for your help!
I had to put some white space in between the files because it was concatenating them together like: file.txtfile2.txtfile3.txt, is this the acceptable way of doing it (below)?
Code:
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
int i;
char theCommand[16384] = "cat ";
for (i = 1; i < argc; i++)
{
strcat(theCommand, argv[i]);
strcat(theCommand, " ");
}
strcat(theCommand, " >> testfile.txt");
system(theCommand);
return 0;
}
What does the system call "dup" do?
What is the difference between dup and dup2
I have a fair idea of what it does but I am confused when its coming down to the exact details...
Please help me!:confused: (2 Replies)
open, creat, read, write, lseek and close
Are they all primitive?
:confused:
*Another Question: is there a different between a system call, and an i/o system call? (2 Replies)
Hi,
I'm new to UNIX system calls. Can someone share your knowledge as to how exactly system calls should be executed?
Can they be typed like commands such as mkdir on the terminal itself? Also, are there any websites which will show me an example of the output to expect when a system call like... (1 Reply)
hi, i'm a noob
i have a quuestion: is possible to call and run the bash script by c++ program?
if so, is it posible in grafic? specially Qt ?
thanks (8 Replies)
Hello,
how would i be able to call ps in C programming?
thanks,
---------- Post updated at 01:39 AM ---------- Previous update was at 01:31 AM ----------
here's the complete system call, ps -o pid -p %d, getpit() (2 Replies)
Discussion started by: l flipboi l
2 Replies
LEARN ABOUT MINIX
diff
DIFF(1) General Commands Manual DIFF(1)NAME
diff - print differences between two files
SYNOPSIS
diff [-c | -e | -C n] [-br]file1 file2
OPTIONS -C n Produce output that contains n lines of context
-b Ignore white space when comparing
-c Produce output that contains three lines of context
-e Produce an ed-script to convert file1 into file2
-r Apply diff recursively to files and directories of
EXAMPLES
diff file1 file2 # Print differences between 2 files
diff -C 0 file1 file2
# Same as above
diff -C 3 file1 file2
# Output three lines of context with every
diff -c file1 file2 # Same
diff /etc /dev # Compares recursively the directories /etc and /dev
diff passwd /etc # Compares ./passwd to /etc/passwd
DESCRIPTION
the same name, when file1 and file2 are both directories" difference encountered"
Diff compares two files and generates a list of lines telling how the two files differ. Lines may not be longer than 128 characters. If
the two arguments on the command line are both directories, diff recursively steps through all subdirectories comparing files of the same
name. If a file name is found only in one directory, a diagnostic message is written to stdout. A file that is of either block special,
character special or FIFO special type, cannot be compared to any other file. On the other hand, if there is one directory and one file
given on the command line, diff tries to compare the file with the same name as file in the directory directory.
SEE ALSO cdiff(1), cmp(1), comm(1), patch(1).
DIFF(1)