473,499 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing array of characters help

2 New Member
GDay everyone,

I'm a newbie in C programming.
Please help me if you're interested in.

How can I pass an array of characters in function 1 to function 2 in C.

Thanks in advance.


eric
Sep 17 '06 #1
5 4123
D_C
293 Contributor
Expand|Select|Wrap|Line Numbers
  1. void passArray(int array[]);
works for integers, so if all is right in this world, change int to char and it should work.
Sep 17 '06 #2
Banfa
9,065 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1. void passArray(int array[]);
works for integers, so if all is right in this world, change int to char and it should work.
Produces code identical to

Expand|Select|Wrap|Line Numbers
  1. void passArray(int *array);
  2.  
In fact in both cases array is of type int *. Tehre are various arguments for and against each type of declaration.
Sep 17 '06 #3
pukur123
61 New Member
The guy is talking about the array of characters.

So the function prototype should be of

data_type function(char *, int);

Here the second argument will specify the total number of characters in the character array you passed.
Sep 18 '06 #4
Banfa
9,065 Recognized Expert Moderator Expert
The guy is talking about the array of characters.

So the function prototype should be of

data_type function(char *, int);

Here the second argument will specify the total number of characters in the character array you passed.
Not necessarily, all the string functions take an array of characters but don't require the size because of the NULL terminator.

What you say may be true but you don't have enough information to say because he hasn't said what the contents of his array of characters will be.
Sep 18 '06 #5
pukur123
61 New Member
See Banfa the guy clearly mentioned that he is passing an array of characters. So it may or may not terminate with null character. But a string will definitely terminate with a null character. So in the first case it is required to know priorly how many characters are there in the array.
Sep 19 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

58
10042
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
1
2519
by: Foxy Kav | last post by:
Hi everyone, im a first year UNI student doing a programming subject and im stuck on how to get rid of my global variables, char stringarray and char emptystring. I was wondering if anyone could...
8
4093
by: kalinga1234 | last post by:
there is a problem regarding passing array of characters to another function(without using structures,pointer etc,).can anybody help me to solve the problem.
4
2481
by: hello smith | last post by:
I have a lot of functions that add values to an array. They alos update a global variable of type int. Currently, I use a global variable to hold this array. All functions access this array...
10
3122
by: Pete | last post by:
Can someone please help, I'm trying to pass an array to a function, do some operation on that array, then return it for further use. The errors I am getting for the following code are, differences...
11
8091
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
2
4399
by: luis | last post by:
I'm using ctypes to call a fortran dll from python. I have no problems passing integer and double arryas, but I have an error with str arrys. For example: ..... StringVector = c_char_p *...
8
3480
by: S. | last post by:
Hi all, Can someone please help me with this? I have the following struct: typedef struct { char *name; int age; } Student;
13
2680
by: masso600 | last post by:
char word; in = fopen("test.txt", "r"); while(fscanf(in,"%s",&word)!=EOF) { /* Print all words */ /* printf("%s\n",&word); */
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7006
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
4597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.