Solved

initialization of values

Posted on 2006-11-07
11
218 Views
Last Modified: 2010-04-15
how can i add 7 integers from the command line which are initialized to 9.

So for e.g. at the command line i create a file hello and then put 7(integers) and then 9(initialization value)

.\a.out hello 7 9


so all the values in the file are initialized to 9 when reading the file.
0
Comment
Question by:junaid_raja30
  • 2
  • 2
  • 2
  • +2
11 Comments
 
LVL 45

Expert Comment

by:Kdo
ID: 17892469

Hi junaid_raja30,

I'm not sure what you're asking.  Do you just want to write '7' and '9' into the file since they were passed on the command line?

0
 
LVL 84

Expert Comment

by:ozo
ID: 17893087
is this homework?
what part are you having difficulty with?
0
 

Author Comment

by:junaid_raja30
ID: 17893833
Yeah I want to right 7 and 9 into the file since they were passed on the command line.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 84

Expert Comment

by:ozo
ID: 17893909
you might want to do the write in a loop.
0
 

Author Comment

by:junaid_raja30
ID: 17894148
in what way? example?
0
 
LVL 24

Accepted Solution

by:
fridom earned 125 total points
ID: 17896266
fopen, fprintf, fclose. will surely help

Pseudo code

open the file fopen(fiel_name, "w+");

looping from
i = 0; i < atoi(argv[2])....
   fprintf("%s ", argv[3]);


fclose(file_handle)

That's all there is to do.

Regards
Friedrich
0
 
LVL 1

Expert Comment

by:nitinmathur5
ID: 17897203
1) Get the arguments from the command line (argc, argv).
2) Allocate memory for your variables (malloc or new).
3) Initialize the variables to the desired value

I hope you get the hint. or correct me if I am wrong
0
 
LVL 24

Expert Comment

by:fridom
ID: 18062733
sorry, what's the problem with my proposal?

Regards
Friedrich
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
why debugging a macro i s difficult 10 33
stack 22 166
Need to explain what is Ambiguous Permutations and why the solution works . c++ 5 140
What is atomic operation? 6 59
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question