Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

initialization of values

Posted on 2006-11-07
11
Medium Priority
?
241 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
11 Comments
 
LVL 46

Expert Comment

by:Kent Olsen
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

670 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