Hi,
Can you explain to me why I can't initialize in this way:
What is the correct approach?Code:c_function(char* arr); int main(int argc, char* arr[]){ : : c_function(argv[1]); : : }
NOTE: this is not a complete code.
Hi,
Can you explain to me why I can't initialize in this way:
What is the correct approach?Code:c_function(char* arr); int main(int argc, char* arr[]){ : : c_function(argv[1]); : : }
NOTE: this is not a complete code.
That's a function call.
Where's the initialisation question?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Looking at your code what i can see just this
1. You have a main function which takes the command file arguments
2. You have a function called c_function which takes string as an argument.
3. And in the main you send the second command line argument to the function c_function.
And here is the question to you. What are you trying to initialize. Is it the argv[1]? If not what is it you wanted to do?
Always try give more information, if you expect something good from others.
ssharish2005
Last edited by ssharish2005; 06-10-2007 at 04:46 AM.
Maybe because you have arr as a parameter of main and passing argv as a parameter of c_function?
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
that would be more likely an error
ssharish2005