Hello,
I wrote this simple program which prints all the arguments given to a program.
My code is straightforward and this is it
Code:
#include <stdio.h>
#include <malloc.h>
int i = 0;
int main(int argc, char** argv)
{
printf("\nargc == [%d]",argc);
printf("\nthe arguments are ");
for(i=0;i<argc;i++)
{
printf(&q
I am trying to compile a simple program using OpenCV in Ubuntu Quantal. I have installed all the OpenCV packages available.
Code of baul :)
Code:
/*
* Hanx [Proyecto Fedora Peru] wth Code
* crc.c - app
*
* This program is private version, for anti-educational purposes and without any
* explicit or implicit warranty; in no event shall the author or
* contributors be liable for any direct, indirect or incidetal damages
To start off with this is a homework assignment for my Operating Systems course and I am stumped.
The prof wants us to read in a source code file and take out all the comment lines and then output the file back into a new source code file.
see i have below code
#include<stdio.h>
int main ( int argc, char *argv[] )
{
int i=0;
for(i=1;i<argc-1;i++)
printf(" %s \n",argv[i]);
return 0;
}
compiles and run as follows
gcc test.c
./a.out 1 * 2
and now its o/p is scarred..!
o/p is :
1
a.out
Desktop
Documents
Downloads
ipmsg.log
linux-fusion-3.2.6
Music
Pictures
Public
Te
#include <fcntl.h>
#include <stdlib.h>
int fdrd,fdwt;
char c;
void rdwrt();
main(int argc,char *argv[])
{
if(argc!=3)
exit(1);
if((fdrd=open(argv[1],O_RDONLY))==-1)
exit(1);
if((fdwt=creat(argv[2],0666))==01)
exit(1);
fork();
rdwrt();
exit(0);
}
void rdwrt()
{
for(;;)
{
if(read(fdrd,&c,1)!=1)
return;
Original source code :#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char** argv) {
int max = -1;
int mb = 0;
char* buffer;
if(argc > 1)
max = atoi(argv[1]);
while((buffer=malloc(1024*1024)) != NULL && mb != max) {
memset(buffer, 0, 1024*1024);
mb++;
printf("Allocated %d MB\n&quo
/*
* program accept argument from stdin as well as command line
* run it with
* echo "1 2 3" | ./a.out
* OR
* ./a.out 1 2 3
*/
#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[])
{
int fromstdin = 0;
int i = 1;
char infile[200];
if (argc == 1) fromstdin = 1;
if (fromstdin)
{
memset(infile, 0, 200);
while (scanf("%s", infile) != EOF
Guys, I have the following code
Code:
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
void read2();
main(int argc, char** argv)
{
int pid,status;
pid=fork();
if ( pid == 0 )
{
read2(argv[1], argv[2]);