Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>strcpy(xmlToken[e_MSISDN],pline->user_info.msisdn);

user_info is the name of a structure, not a member of ds. That line should be this: strcpy(xmlToken[e_MSISDN],pline->ui.msisdn); Now that line has another problem -- msisdn is an integer, and you can't use strcpy() on it. You can use sprintf() to convert the int to a string.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

i dont know actually how to use gdb.

please u try once from your side to debug and find the solution.

And please teach to about the usage of gdb.

Thanks,
DP

Well why don't you learn how to use gdg? Start with google.

>>please u try once from your side to debug and find the solution.
DaniWeb is not your a debugger.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm only going to say this once more -- post the file, dummy it up with fake names if you want, but we need your file to work with. The example lines you posted in post #1 don't work

Deepak|23|M
puja|21|f
|XY|

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

When you double click on the button as I showed previously the VC++ 6.0 IDE will create the correct message map entry for you -- you do NOT have to code that yourself. After clicking that button, the message map in the *.cpp file should like something like this:

BEGIN_MESSAGE_MAP(CDlgtestDlg, CDialog)
	//{{AFX_MSG_MAP(CDlgtestDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

And in the *.h file

protected:
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CDlgtestDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnButton1();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
}

Attached is the complete project I made, minus compiler-generated files.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The two friend functions must return a reference to the istream and ostream objects. Here's correction

#include <iostream>
#include <string>
#include <cstring>
using namespace std;
#pragma warning( disable: 4996) // only needed for VC++ 2008 compiler

class aName
{
friend std::istream& operator>>(std::istream & input,aName &name);
/*input the name from the standard input stream like the keyboard and the name is never empty*/
friend std::ostream& operator<<(std::ostream & output,aName name);
//it displays the name on the standard output like the screen

private:
char*surname,
    *firstname;

public:
    aName() { surname = NULL; firstname = NULL;}
    aName(char *aSurname,char*aFirstname)
    {
        surname = NULL; firstname = NULL;
        set(aSurname, aFirstname);
    }

    void set(char** name, const char* aName)
    {
        if( *name != NULL)
            delete[] *name;
        *name = NULL;
        if( aName != NULL)
        {
            *name = new char[strlen(aName)+1];
            strcpy(*name, aName);
        }
    }
    void set(const char *aSurname,const char* afirstname)
    {
        set(&surname, aSurname);
        set(&firstname, afirstname);
    }
};

istream& operator>>(istream& in, aName& nm)
{
    // TODO:  complete this function.
    return in;
}

int main()
{
    aName n;
    cin >> n;
}

[edit]Oops! I just noticed I did half your homework:(

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>surname=aSurname;

First you have to allocate space for surname then call strcpy() to copy it

surname = new char[strlen(aSurname)+1];
strcpy(surname, aSurname);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

put links to SNIPPED in your signature then contribute to the discussions here at DaniWeb.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You need to post the input data file (zip it up first!) because the program you posted produces these errors on the three example lines you posted in your post #1.

Dml Error: at line 1
Dml error: Missing ; at line 2
Press any key to continue . . .

it works upto 10 columns.

when the column name exceeds 10

it shows "segmentation fault"

>>record->column_delim=(char**)malloc(10*sizeof(char*));

That line looks awfully suspicious of the reason for your error. It is only allocating room for 10 pointers

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you are on MS-Windows why not just use win32 FONT structure and call win32 api functions to populate it. This might help you.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

i have written the code in notepad and compiled in UNIX environment with gcc compiler .

The most horrible programming environment ever. Why code it on Windows and compile it on *nix? You have a perfectly good IDE on *nix called vi, and I know for a fact there are even better ones. On Windows you have several free IDEs that will do auto-intent -- VC++ 2008 Express and Code::Bocks are just two of them. Learn to use IDEs because they will make your life a lot simpler so that you can become a more efficient coder.

And if you still insist on using Notepad, I know it has a tab key -- learn to use it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The program may not display the data immediately after calling cout, but hold it somewhere in memory until there is enough data to be displayed. That behavior saves a lot of time because displaying text is pretty cpu intensive. The flush() function forces the os to output the data to the output stream immediately instead of waiting for the output buffer to fill up.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 17: the value of ch is undefined. Similar problem with all the other variables declared in that function. Variables have to be initialized with something before using them.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>will there be a newline in the buffer after running this code?
Yes, and I think we have already explained that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
serkan sendur commented: i just wanted to add to your reputation papa +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Instead of trying to convert line-by-line, try converting function-by-function. First thing to do is create a c++ class then make all those functions class methods. Next, replace the linked list with a vector of structures. Avoid use of all those global variables -- pass them as parameters to the functions which use them.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 21 and 24: >> for(int x;x<width;x++)
You forgot the variable initializer. Should be like this: for(int x = 0;x<width;x++)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Why don't you do it yourself? It will take a lot of effort to change FILE to ifstream/ofstream, and character arrays to std::string. You would be better to do the conversion yourself instead of asking others to do it for you for free.

Of course you could always just use the code as it is.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Search http://www.codeproject.com/ -- they have some win32 api printing examples.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Sorry for the long delay in answering, but you will most likely have to use ODBC. Just google for "ODBC C++ classes" and you will find some links. There is also an ODBC tutorial

For MySql, there is a MySQL++ tutorial

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Install and try FireFox and see if it has that same problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Now how in hell do you think anyone can answer that question? "My car is broke, please make it better".

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

After fixing up some unidentified macros

const int e_LASTCOUNT = 10;
const int e_MESSAGETYPE = 0;
const int e_MSISDN = 1;
const int e_TRANSACTION_ID = 2;

void IVR_AL_GET_VM_RETRIEVAL_PROFILE_REQ(ds *pline, char xmlToken[e_LASTCOUNT][5000])
{
   strcpy(xmlToken[e_MESSAGETYPE],"GET_VM_RETRIEVAL_PROFILE_REQ");
     strcpy(xmlToken[e_MSISDN],pline->user_info.msisdn);
     strcpy(xmlToken[e_TRANSACTION_ID],pline->transactionId);

     return;
}

I got this error which you need to fix
>>error C2039: 'user_info' : is not a member of 'ds'

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>This and other "new" ways of doing things makes it seem as if Microsoft is inventing a whole new language.

They did :) CLR != C++ != C#

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You usually have to clear the input buffer

  1. After entering numeric data, such as short, int, long, float and double
  2. After using cin >> input operator because it stops at the first space
  3. After using a character array that is smaller than the number of characters typed at the keyboard

The code you posted is an infinite loop unless you press Ctrl+Z at they keyboard.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The project is probably not linking with the library that is produced for that dll, most likely akrip32.lib, or libakrip32.a, or something like that.

Stefano Mtangoo commented: You helped me alot! +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>s = new_cstring;

That is only changing the local copy of the string, not the original. Do not create a new character array, but work directly with the pointer that is in the parameter to that function.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'd suggest the OP compile the code then run it to see what it does.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Its the raw data that cannot be compressed not a single integer!
Yes I realize that -- but memory address are unsigned integers. The size of any pointer is the size of an integer, and the size of an integer depends on the operating system (8, 16, 32, 64, 128 bits etc). I'm talking about memory address, not what's stored in them.

Maybe you should investigate operating systems other than Windows, MAC and *nix. For example IBM mainframes.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Do you have a reason for posting all that code ???

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I would start at the beginning and use a pointer to find the first type of the sequence, then memcmp() to determine if it is the first byte of the entire sequence. Something like this (but may not really work in managed programs. I don't write managed code programs so don't be surprised if this doesn't compile correctly.).

unsigned char* ptr = fileContents;
Object^ search = '\x6E' + '\x73' + '\x61' + '\x76' + '\x00' + '\x00' + '\x00' + '\x01';
unsigned char* searchPtr = search;
for(int i = 0; i < fileContents.Length; i++, ptr++)
{
    if( *ptr == *searchPtr )
    {
        if( memcmp(ptr, searchPtr) == 0)
        {
            // found it!
       }
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

A 64-bit integer can hold a maximum value of the value defined in limits.h -- 0xffffffffffffffffui64 If you put that value in a calculator and convert from hex to decimal it will be 18,446,744,073,709,551,615. According the chart in this link, that is about 18 Exabytes. That would be more than enough to reach far beyond the maximum capacity of any known computer. I don't know enough about hardware architecture to explain why a 64-bit program can not access the entire computer's memory. Possibly Windows 7 (release date in Oct 2009) will alleviate that.

I don't know if *nix can help you better or not because I don't use it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Is Array::BinarySearch() something you coded? And if it is, then please post it. Binary searches only work on sorted data. So if the data isn't sorted than the program must do a linear search.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 18: should be this: if ( strcmp(file,"*.tar") == 0) The way you had it was comparing two address, not their contents. But Vernon is right about using strstr() to see if ".tar" was entered in the file name.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I would think 64Gig RAM access would be more than sufficient -- I don't think computers can hold that much RAM anyway (yet). The maximum ram supported by Vista Ultimate is 128Gig.

The maximum RAM is more limited by hardware (motherboard) than operating systems.

And yes, Microsoft compilers (VC++ 2008) contains 64-bit version of the compiler (all editions except Express). 64-bit version must be specified during compiler installation.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There is no such thing as "unlimited addressing capabilities." -- all operating systems have limits.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Hi

Sorry to bother but none of the statements are working. Can you please sugesst alternatives.

Thanks

Post the code you have tried.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There are people all over the planet who apparently think God said "trains" instead of "brans", and told Him "No thanks.".

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is how to cut a section out of a std::string

int main()
{
    string str = "Now is the time";
    str.erase(4,3);
    cout << str << "\n";
}

In your code, instead of 4,3 str.erase(textBox1.SelectionStart,textBox1.SelectionLength); [edit]Too late -- already suggested :)[/edit]

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Look at the function I posted above. All you have to do is change the parameter types in the three overloads

MyString MyString::operator+(const MyString& rightOp) const
MyString MyString::operator+(const char* rightOp) const
MyString MyString::operator+(const std::string& rightOp) const
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

also write the values of col_max and row_max so that they can be read back at runtime

mat_file.write(reinterpret_cast<char*>(&row_sz), sizeof(int));
mat_file.write(reinterpret_cast<char*>(&col_sz), sizeof(int));
#include <iostream>
#include <fstream>
using namespace std;
#pragma warning(disable: 4996)

int matread(float*& mp,int& row_sz,int& col_sz,string mat_file)
{
    ifstream in(mat_file.c_str());
    in.read(reinterpret_cast<char*>(&row_sz), sizeof(int));
    in.read(reinterpret_cast<char*>(&col_sz), sizeof(int));
    mp = new float[row_sz*col_sz];
    
	in.read(reinterpret_cast<char*>(mp),row_sz * col_sz * sizeof(float));
    return 0;
}

int main()
{
   float *ay = NULL;
   int row_sz = 0, col_sz = 0;
   matread(ay,row_sz, col_sz, "filename.txt");

}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Don't you want this function to be outside of the class?

class MyString
{
    // ...
};

MyString operator+ (const MyString &lhs, const MyString &rhs)
{
    return MyString(lhs) + MyString(rhs);
}

Or something like that?

No -- that is illegal syntax for non-class methods.

error C2270: '+' : modifiers not allowed on nonmember functions

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yup -- I tested that too and it compiled ok.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

make it a reference parameter, not a return value

void f(vector<vector<int>> & ay)
{
   // fill in the vector
}

int main()
{
    vector<vector<int>> ay;
    f( ay );
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I see two things wrong:
1) remove the const keyword at the end -- the function is not const because it changes the value of stringStorage.

2)You need another class object. What you wrote was for the += operator, not the + operator.

MyString MyString::operator+(const MyString& rightOp)
{
    MyString tmp = *this; // requires overloaded = operator
    strcpy(tmp.stringStorage, rightOp.stringStorage);
    return tmp;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well, if you don't want the user to press a key then delete the cin.get() lines -- that's what that function is used for.

>>cin.get() is discarded somehow.
Probably because a previous cin operation was for an integer, which leaves the '\n' in the keyboard buffer, and the next cin.get() will remove that '\n' from the keyboard buffer and toss it away.

int num;
cout << "Enter a number\n";
cin >> num;
cin.ignore(); // flush the '\n' from keyboard buffer
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

We don't know the purpose of each argument other than that was what you wanted. In the format string, %s stands for a string, and %d is for an integer. There are a lot of other formats too but you need to read about them either in a text book or online.

As for FileName and filename, the first one is for user input and the second one is what the program will construct. Can't be done with just one variable. Well, that's not quite correct, but its much easier to use two character arrays instead of one.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you mean if the user types "Hello World" <Enter key>, you want to add '\n' to the end of the string?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

AFAIK, it's not exactly *free*.

There is a free trial version, but probably for a limited time before must buy the full version.