The way you're using strcpy is incorrect. Neither char *script nor char *text point to properly allocated memory. Instead, they are uninitialized and pointing to arbitrary locations. You may get lucky, or you may segfault.
So I need to use malloc first and then do the assign operation. I made the following changes :
and
Quote:
Originally Posted by alister
char *content points to 1000 bytes, but the code does not prevent a long reminder from overflowing the buffer. In this case, you could get the job done with a single fprintf. Why construct a string in a buffer when you can write the text directly to the stream?
Ok so I will include a check for the size of the text entered by the user and then if its larger than the allowed limit, I will set it to a default value.
Quote:
Originally Posted by alister
Using atoi in new code is asking for trouble, since it does not perform any type of error checking.
Include a validation for this as well.
Quote:
Originally Posted by alister
The -k start|stop switch is redundant with the presence of -t. You can set all of the appropriate (int) flags based on the presence or absence of -t.
Actually I have made only the -k start/stop option mandatory. The other two are optional. So if the user do not give them, both the reminder text and the countdown will be set to a default value.
Quote:
Originally Posted by alister
I did not try to compile the program. I only skimmed the code. There may be other issues lurking. If you haven't done so, enable all of your compilers warnings.
I enabled all the warnings and I got the below output:
For the first warning I did a type casting to int.
and for the second one I included the sys/wait.h
But still my question remains. How do i make the program stop?
Now I am doing Ctrl-C from the prompt to end the program.
How can I make it stop when I enter ./reminder -k stop
Thanks
---------- Post updated at 06:33 AM ---------- Previous update was at 05:00 AM ----------
So I have made the changes and this is a working copy. And I found an interesting feature. If I give the reminder text as ';rm a;echo ', the file a actually gets removed. So I can give anything between the semi-colon and the script will execute it. Interesting...
If I want to write program that spread the work to its child process so that each process compute some task what should I do?
The objective of my program is to fill in the table which (10*10) in dimension and each column is filled with the fibonacci value of i+j (i mean current row and j mean... (1 Reply)
Dear Experts
Why we always hear that unix operating system is Multi User and Multi task. What does these two means. I have looked at some books and documents but couldn't find aclear explenation. Can we say Windows operating system is also multi user and multi task??
Thanks for your help in... (6 Replies)
Hi,
Am supposed to use message queues to send and receive messages between the processes. when i was working on that i realised that the message qid and the message queue related data should be maintained in a shared memory so that it can be accessed by all the processes. Could anybody refer... (10 Replies)
Hi,
I'm trying to compile the following code:
/************** Begin <test.c> ***************/
/*
* Compiled with: gcc -Wall -o test test.c
*/
#include <stdio.h>
#include <unistd.h>
int main(void)
{
printf("I'm process %d, son of %d \n", getpid(), getppid());
printf("Hello \n");... (3 Replies)
Hi,
I'm trying to compile the following code:
/************** Begin <test.c> ***************/
/*
* Compiled with: gcc -Wall -o test test.c
*/
#include <stdio.h>
#include <unistd.h>
int main(void)
{
printf("I'm process %d, son of %d \n", getpid(), getppid());
... (5 Replies)
I read that 'Any single program that can run as multiple processes can benefit from OpenMosix: "The GIMP" photo editor and the "kandel" fractal generator are known to do this.
Are there other load-balancing clusters that do support multi-process applications? (1 Reply)
I have a unix directory where a million of small text files getting accumulated every week.
As of now there is a shell batch program in place which merges all the files in this directory into a single file and ftp to other system.
Previously the volume of the files would be around 1 lakh... (2 Replies)
Hi,
I have a problem where I need to make this input:
nameRow1a,text1a,text2a,floatValue1a,FloatValue2a,...,floatValue140a
nameRow1b,text1b,text2b,floatValue1b,FloatValue2b,...,floatValue140b
look like this output:
nameRow1a,text1b,text2a,(floatValue1a - floatValue1b),(floatValue2a -... (4 Replies)
I am trying to write a large X app. I have successfully modified my xorg.conf to setup 4 monitors on an NVIDIA Quatro5200. I am trying to modify a simple hello world application to open a window on three of the four monitors. depending on the changes to loop the window creation section and event... (2 Replies)
hi
I want to call a lot of links with the post method
What to do to speed it up??
####This method is slow
#!/bin/bash
func2() {
index1=0
while read line ; do
index1=$(($index1+1))
url=$line
done < tmp/url1.txt
} (10 Replies)