473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Whats the meaning of this code

sam
HI,
Whats the meaning of this code:-

char buff[100];
memset(buff, 'A' , 100);
sometimes we can place hex value in
place of 'A' like 0x90c
but how this code function actually.

thanks in advance

Apr 23 '07 #1
5 2988
sam wrote:
HI,
Whats the meaning of this code:-

char buff[100];
memset(buff, 'A' , 100);
sometimes we can place hex value in
place of 'A' like 0x90c
I doubt that 0x90c can replace 'A' generally. The value 0x90c
is larger than the value a 'char' object can contain (usually).
but how this code function actually.
The declaration/definion of 'buff' functions by declaring and
defining that array. It's left uninitialised. How exactly it
is allocated is unspecified. Elements of 'buff' have automatic
storage duration, most likely (since those two lines of code
are undoubtedly part of a function body).

'memset' is a function, so the second statement calls the
function and passes it three arguments. The description of
'memset' says that it fills the memory pointed to by the first
argument with the value of the second argument, counting the
bytes using the third argument. IOW, the entire array 'buff'
gets filled with characters 'A', all 100 elemenst of 'buff'
will have the value 'A' after 'memset' returns.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Apr 23 '07 #2
On Apr 23, 9:05 am, sam <sameer...@gmail.comwrote:
HI,
Whats the meaning of this code:-

char buff[100];
memset(buff, 'A' , 100);
sometimes we can place hex value in
place of 'A' like 0x90c
but how this code function actually.

thanks in advance
This is just setting a memory area (buff) with
initial values.

Apr 23 '07 #3
An**********@gmail.com wrote:
On Apr 23, 9:05 am, sam <sameer...@gmail.comwrote:
>HI,
Whats the meaning of this code:-

char buff[100];
memset(buff, 'A' , 100);
sometimes we can place hex value in
place of 'A' like 0x90c
but how this code function actually.

thanks in advance
This is just setting a memory area (buff) with
initial values.
I would omit the word "initial" from this explanation.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Apr 23 '07 #4
sam
On Apr 23, 6:05 pm, sam <sameer...@gmail.comwrote:
HI,
Whats the meaning of this code:-

char buff[100];
memset(buff, 'A' , 100);
sometimes we can place hex value in
place of 'A' like 0x90c
but how this code function actually.

thanks in advance
I am not saying 'A' is replaced by
0x90c but i am saying we can
place any hex value as per
requirement in place of 'A'
and I want brief explanation.

Apr 23 '07 #5
sam wrote:
On Apr 23, 6:05 pm, sam <sameer...@gmail.comwrote:
>HI,
Whats the meaning of this code:-

char buff[100];
memset(buff, 'A' , 100);
sometimes we can place hex value in
place of 'A' like 0x90c
but how this code function actually.

thanks in advance

I am not saying 'A' is replaced by
0x90c but i am saying we can
place any hex value as per
requirement in place of 'A'
and I want brief explanation.
An explanation would probably be that 'char' is a type that
can store values (of a certain range). 'A' represents a value
that can be stored in a 'char' object. So does 0 and any
other integral that can be converted to 'char'. The hex
notation is just a way of representing the value. For example,
in ASCII, 0x41 is the hex equivalent of 'A' (the capital form
of the first letter of the Latin alphabet). 65 is the decimal
equivalent of 0x41 (and of 'A'). 0101 is the octal equivalent.

RTFM on memset. Then build a minimal program with your code
and run it under a debugger, looking at the elements of the
array 'buff' as you step through your code.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Apr 23 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: smileplzz | last post by:
r there any files which we can download from this group. can we only ask questions in this group? no files stored like it is there in yahoo groups. i think it should be there in group services....
3
by: news.microsoft.com | last post by:
Hi, I have an app with three forms. a) Master form. It has a grid with a list of contact names on it. b) Contact form. This form is where you can edit/create a new contact c) address form....
34
by: Spidey | last post by:
What kind of formating can be done with %p in printf
6
by: cool17 | last post by:
Hi can somebody tell me what does this line means in the c programming "typedef struct terms* express;"? thank
3
by: nahiyan13 | last post by:
hey there I have been given a problem where i have to write a function integerPower(base,exponent)that returns the value base^exponent(in words meaning if base is 2 and exponent is 3 then the...
1
by: Gert Cuykens | last post by:
rex2=re.compile('^"(?P<value>*)"$',re.M) File "/usr/lib/python2.5/re.py", line 180, in compile return _compile(pattern, flags) File "/usr/lib/python2.5/re.py", line 233, in _compile raise...
3
by: sam | last post by:
HI, The code is as follows:- #include <stdio.h> 1 2 void * work(void * ptr) 3 { 4 int i; 5 for (i = 0; i < 10; i++) 6 {
14
by: nobrow | last post by:
Yes I know what lvalue means, but what I want to ask you guys about is what are all valid lvalues ... a *a a *(a + 1) .... What else?
7
by: moondaddy | last post by:
I'm writing and app in c#2.0 (converting from vb) and would like to know what I should replace the vb Now function with. Thanks. -- moondaddy@noemail.noemail
8
by: 2b|!2b==? | last post by:
typedef struct llist_entry_s llist_entry; /* opaque type */ struct llist_entry_s { llist_entry * next; char * keyword; char * value; llist_entry() :next(0), keyword(0), value(0) {
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...

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.