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
Solved

initialization of values

Posted on 2006-11-07
11
225 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: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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files 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.

860 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