Solved

initialization of values

Posted on 2006-11-07
11
197 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
Comment Utility

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
Comment Utility
is this homework?
what part are you having difficulty with?
0
 

Author Comment

by:junaid_raja30
Comment Utility
Yeah I want to right 7 and 9 into the file since they were passed on the command line.
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
you might want to do the write in a loop.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:junaid_raja30
Comment Utility
in what way? example?
0
 
LVL 24

Accepted Solution

by:
fridom earned 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility
sorry, what's the problem with my proposal?

Regards
Friedrich
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now