0x00 In C - C Board
- Register
- Remember Me?
- Advanced Search
- Forum
- General Programming Boards
- C Programming
- 0x00 in C
-
Thread Tools
- Show Printable Version
- Email this Page…
- Subscribe to this Thread…
-
Search Thread
- Advanced Search
-
Display
- Linear Mode
- Switch to Hybrid Mode
- Switch to Threaded Mode
- 08-16-2009 #1 vandrea
- View Profile
- View Forum Posts
0x00 in C
Hi all, Just had q query wrt to the string "0x00" used in memset of character arrays in C. Could anyone reply on this!! Thanks, Vandrea
- 08-16-2009 #2 Sebastiani
- View Profile
- View Forum Posts
I don't understand your question. You don't pass a string to memset. If you're talking about the integral constant 0x00, it's just the hex encoding of, well, 0.
- 08-16-2009 #3 vandrea
- View Profile
- View Forum Posts
yep u were right..i meant of the integral constant! Consider the follg eg: Code: char abc_ca[3]; memset(abc_ca,0x00,size(abc_ca)); So after the above memset i would have following values in my string Code: abc[0]={'\0'} abc[1]={'\0'} abc[2]={'\0'} where {'\0'} identifies the end of string...Just wanted to know if my understanding is right!
- 08-16-2009 #4 Sebastiani
- View Profile
- View Forum Posts
Yep. On a side note, though, just keep in mind that sizeof used in that way won't work on an array passed to a function or on a pointer to an array.
- 08-16-2009 #5 vandrea
- View Profile
- View Forum Posts
Thanks Sebastiani for the quick reply...but dint get as to why cant we use sizeof in memset ?
Last edited by vandrea; 08-16-2009 at 04:22 AM. Reason: error
- 08-16-2009 #6 Sebastiani
- View Profile
- View Forum Posts
Well, for example: Code: int main( void ) { char buf[ 1024 ], * ptr = buf; printf("sizeof( buf ): %d\n", sizeof( buf ) ); printf("sizeof( ptr ): %d\n", sizeof( ptr ) ); return 0; } And when you pass an array to a function, it resolves to a pointer, so the effect is the same as in the second print statement.
- 08-16-2009 #7 vandrea
- View Profile
- View Forum Posts
Well, for example: Code: Code: int main( void ) { char buf[ 1024 ], * ptr = buf; printf("sizeof( buf ): %d\n", sizeof( buf ) ); printf("sizeof( ptr ): %d\n", sizeof( ptr ) ); return 0; } And when you pass an array to a function, it resolves to a pointer, so the effect is the same as in the second print statement. I understood ur example but still wondering as to y cant we use sizeof in the above memset since Code: sizeof(abc_ca) wuld return 3 I guess..
- 08-16-2009 #8 Sebastiani
- View Profile
- View Forum Posts
>> I understood ur example but still wondering as to y cant we use sizeof in the above memset since The point is simply that you can use it on 'buf' but not 'ptr'. And inside a function, you'd have the same problem: Code: void test( char buf[ 1024 ] ) { printf("sizeof( buf ): %d\n", sizeof( buf ) ); }
- 08-16-2009 #9 vandrea
- View Profile
- View Forum Posts
Thanks Sebastiani...Now I get it!
- Site Areas
- Settings
- Private Messages
- Subscriptions
- Who's Online
- Search Forums
- Forums Home
- Forums
- General Programming Boards
- C++ Programming
- C Programming
- C# Programming
- Game Programming
- Networking/Device Communication
- FAQ Board
- Programming Book and Product Reviews
- Platform Specific Boards
- Windows Programming
- Linux Programming
- Cprogramming.com and AIHorizon.com's Artificial Intelligence Boards
- General AI Programming
- Community Boards
- Article Discussions
- Tech Board
- General Discussions
- A Brief History of Cprogramming.com
- Contests Board
- Projects and Job Recruitment
- Exactly how to get started with C++ (or C) today
- C Tutorial
- C++ Tutorial
- 5 ways you can learn to program faster
- The 5 Most Common Problems New Programmers Face
- How to set up a compiler
- 8 Common programming Mistakes
- What is C++11?
- Creating a game, from start to finish
- How to create a shared library on Linux with GCC - December 30, 2011
- Enum classes and nullptr in C++11 - November 27, 2011
- Learn about The Hash Table - November 20, 2011
- Rvalue References and Move Semantics in C++11 - November 13, 2011
- C and C++ for Java Programmers - November 5, 2011
- A Gentle Introduction to C++ IO Streams - October 10, 2011
Similar Threads
-
Encryption/Decryption Help
By coolage in forum C++ Programming Replies: 9 Last Post: 04-25-2008, 01:53 AM -
To generate bar code from a number
By darkducke in forum C Programming Replies: 18 Last Post: 01-16-2008, 06:33 AM -
brace-enclosed error
By jdc18 in forum C++ Programming Replies: 53 Last Post: 05-03-2007, 05:49 PM -
Compile time switch
By Roaring_Tiger in forum C Programming Replies: 13 Last Post: 09-12-2004, 01:16 PM -
Encryption Algorithms
By face_master in forum C++ Programming Replies: 15 Last Post: 06-18-2003, 01:28 PM
Tags for this Thread
[code]View Tag Cloud
-- Normal Style -- Mobile Style -- Default Mobile Style All times are GMT -6. The time now is 11:11 PM. Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved. Search Engine Optimisation provided by DragonByte SEO v2.0.40 (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.Từ khóa » C++ 0x00
-
0x00 And Char Arrays - C++ - Stack Overflow
-
[Solved] How Do I Display 0x00? - CodeProject
-
How To Append To A String A Value 0x00 "00" And Not "\0" Char - MSDN
-
Binding An SSL Certificate To A Port In Windows C++ - Gists · GitHub
-
C++ UART MH Z19 CO2 Carbon Dioxid Sensor - GitHub Gist
-
Cad - Arm Compiler For Embedded Reference Guide
-
ARM Compiler Toolchain V4.1 For µVision Using The Fromelf Image ...
-
Best Way To Point Array To A Method | Spiceworks Tech
-
Cannot Create C++ Project "Hexadecimal Value 0x00 Is An Invalid ...
-
Bit Level Operations
-
SPL Binary Encoding - IBM
-
ASCII Chart & ISO 1252 Latin-1 Char Set