473,545 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3021
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...@gmai l.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**********@gm ail.com wrote:
On Apr 23, 9:05 am, sam <sameer...@gmai l.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...@gmai l.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...@gmai l.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
3838
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. ur new group member Ram 20/m/India
3
1066
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. This form is a popup launch from the contact form to enter the contacts address. I have created a basic class for the contact object. What I want to...
34
2048
by: Spidey | last post by:
What kind of formating can be done with %p in printf
6
4182
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
3276
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 program has to provide 2 to the power 3 which is 8 as an output)Our teacher asked to use a for loop to do this and by noother means.I have written the...
1
5877
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 error, v # invalid expression sre_constants.error: unexpected end of regular expression ?
3
366
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
4352
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
14029
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
1601
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
7478
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7668
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7923
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3466
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
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 we have to send another system
1
1025
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.