Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 972073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:03:51+00:00 2026-05-16T03:03:51+00:00

Hi following code sample seems to have some problem or either it has to

  • 0

Hi following code sample seems to have some problem or either it has to do something with OS internals.

    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <string.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>

    static void usage();
    #define MONC_AM_CONF "/tmp/monc.conf"

int main(int argc, char **argv)
{
        int ch;
        char list[200];
        int len;
        int fd;

        memset(list,0,200);
        if (argc < 11) {
                usage();
                exit(1);
        }

        while ((ch = getopt(argc, argv, "N:S:P:H:R:")) != -1) {
                switch (ch) {
                        case 'N':
                                len = strlen(optarg) + 2;
                                sprintf(list,"%s::",optarg);
                                break;
                        case 'S':
                                sprintf(list+len,"%s::",optarg);
                                len = len + strlen(optarg) + 2;
                                break;
                        case 'P':
                                sprintf(list+len,"%s::",optarg);
                                len = len + strlen(optarg) + 2;
                                break;
                        case 'H':
                                sprintf(list+len,"%s::",optarg);
                                len = len + strlen(optarg) + 2;
                                break;
                        case 'R':
                                sprintf(list+len,"%s ",optarg);
                                len = len + strlen(optarg);
                                break;
                        default:
                                printf ("You specified a parameter I don't "
                                                "know about.\n");
                                break;
                }
        }
        argc -= optind;
        argv += optind;

        printf("Total length of string is %d\n",len);
        printf("The string is %s\n",list);

        fd = open(MONC_AM_CONF, O_WRONLY|O_CREAT|O_APPEND, 0644);
        lseek(fd, 0,SEEK_END);
        write(fd,list,len);
        close(fd);

        return 0;
}

static void usage()
{
printf("Please provide the command in correct format\n");
printf("monc_am_config -N <Comp_Name> -S <Start Script Path> -P <Stop Script Path> -H <HealthCheck Script Path> -R <Recovery Policy>\n");

return ;
}

When I am issuing commands I am getting the output file each time different.
I am expecting execution of this program each time should write the information in the new line but it is writing into the same line in the file.

Plz help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:03:52+00:00Added an answer on May 16, 2026 at 3:03 am

    You should append “\n” to list, i.e

    list[len++] = '\n';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 508k
  • Answers 508k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes its a big mess. It would have been helpful… May 16, 2026 at 4:12 pm
  • Editorial Team
    Editorial Team added an answer update: when you do .addEvent('type', function(){ }) and .removeEvent('type', function(){… May 16, 2026 at 4:12 pm
  • Editorial Team
    Editorial Team added an answer I've found the solution: you have to add istanceNameOfFLVPlayback.fullScreenTakeOver =… May 16, 2026 at 4:12 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a table that, some of its columns are unknown at compile time.
I have a some html being generated by JQuery on a Share Point page.
I have a workspace with the following 3 projects: Library Tests GUI The tests
Following on from this question: ASP.NET MVC Routing with Default Controller I have a
I have a pretty simple table in SQLite, with the following schema: CREATE TABLE
I am currently doing some XML parsing and I've chosen to use Hpricot because
I have text being passed to a function. That text can contain anything, from
I am having a bit of a problem with a functor (and it's resultant
I have a WSDL generated by WCF and now this WSDL should be used
I'm new to Linq. I have searched and searched the web for a solution,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.