If you know the ASCII standard then you know that 'a' has value 65. Now if you want to print out your code for 'a' as 01 then you have to subtract your character first by 65 and then add 1. effectively code of 'b' is ASCII(b) - ASCII(a) +1,
ASCII(b) = 66
ASCII(a) = 65
Therefore ASCII(b) - ASCII(a) +1 = 2.
Next you get to coding. The following snippet considers that the value for the character is only between...
User Profile
Collapse
-
I too had the same doubt. However I tried it out and it seemed to work fine. I made the following observations though. The order of execution of the function is not defined. This is compiler dependent. Next thing is that the function should generally not be a instance member function, since we cannot count on the object to be completely initialized.
Consider the following code:
[code="c++"]
class TestClass...Leave a comment:
-
I repaired the code to this and it works fine. (on VC and gcc atleast). This avoids the name clash problem as pointed out above. The
Code:using std::cout;
Code:#include <iostream> #include <string> using std::string; using std::cin; using std::cout;
Leave a comment:
-
Query on Using XML file for Database
I wanted to create a small blog component for a website using C#. I do not have
MSSQL. So i thought i would use a xml file as a database. I also created the xsd and linked it to the xml. Is it a good choice to use a xml instead of a database. Updates are very rare. Presently i am able to load the xml into a dataset and search through it. How do i update new data? Also at what frequency should i update the data file? -
should be replaced by
[code=cpp]
if(strncmp(text ,"quit",4) == 0){
[/code]...Leave a comment:
-
keerthiramanarayan replied to Is Libcap library is capable to capture all types of packet from switch?in CHi,
I happened to use libpcap for a prototype of a packet forwarder. As far as i know, the libpcap library can capture any packet which comes to your MAC (Network Card). But one exception i noticed was that libpcap does not capture packets that originate and are destinated for the localhost (loopback). Guess u can use any of the tools that use libpcap (wireshark etc.) to find out if it is really what u want to use....Leave a comment:
-
I would like to add to the above reply. You should refrain from using the .h when including standard c++ libraries. So preferably use
[code=cpp]
#include <iostream>
[/code]
instead of
[code=cpp]
#include<iostre am.h>
[/code].
You have used the notation for string but have not done so in the case of iostream....Leave a comment:
-
Thanks Jos. I will be more carefull while using recursion next time :)...Leave a comment:
-
First of all i would ask you to see the Posting Guidelines.
Coming to the solution, do you really require a class for something that holds only data. You would be better off storing the data as a structure. Next, to support portability and easy retrieval, it would be better if you wrote each member separately into the file. The runtime may arrange each type differently and cause problems. Try writing(reading ) each field separately...Leave a comment:
-
Such Programs can be easily specified using Grammars and can be converted to C Programs using Lex and Yacc. However for the specific purpose of matching braces, i doubt if your algorithm will work for all cases. The best way to tackle the matching program is by recursion. Enter when you get the left brace and leave when you get the right brace.Leave a comment:
-
From what i can make out you do not have a function which iterates through the list and finds the name.
For such a function you would need how many records you read from the file (missing in your code). You can return the count from the function.
Secondly you need to include the following code in a for / while loop...Leave a comment:
-
The map in your case will be initialized to 0.00 . However it is not the case with types such as strings or user classes. which tend to by null(0). So you should be careful.Leave a comment:
-
Hi,
It would be easy to reply to your query if you specified the structure of address book.
I will explain considering that your addressbook entry contains the data in the following format
<First Name> <Last Name> <Phone Number>.
You would be greatly helped by creating a structure that holds the data that you read from the file as follows.
Code:#include <string>
Leave a comment:
No activity results to display
Show More
Leave a comment: