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

Go ahead, nobody here will stop you :)

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

It isn't necessary for you to manually put all those line numbers in your code -- the code tags will do that for you.

This tells you to use code tags - http://www.daniweb.com/forums/forum2.html
So does this - http://www.daniweb.com/forums/forum8.html
Wait for it, wait for it - http://www.daniweb.com/forums/announcement8-3.html
You're not going to believe this - http://www.daniweb.com/forums/thread78223.html
And not forgetting the watermark at the back of the edit window.

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

yes and yes. There is a small amount of code that gets executed before main() which sometimes allocates memory too.

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

Welcome to DaniWeb

>>Favorite Movies: Rambo is having sex change
Now that would be a funny movie :)


>>Favorite Video Games: Don' have that here, please explain whats that
Of course you people have vide games. If you are near a Wal-Mart than it will have hundreds of them.

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

what programming language is that ? Need to move this thread to the appropriate board for that language.

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

Yes I can help you but not write the program for you. Give it a try yourself and post what you have done.

To find the size of the file first use FILE pointer and call fopen() to open it for reading, then call fseek() to move the file pointer to the end of the file, call ftell() to get current location, which will be the file size. After that call fclose() to close the file handle. Now you have all the information to do the calculations.

You will have to read your textbook to find out how to use each of the functions I mentioned above. You can also find them online by using google.

Aia commented: Sound advise +7
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Can anyone please tell me how to store contents of a text file after reading it into a 1D array buffer

char buf[1024];
// not read the file into the above array

>>and then accessing each separate element of the paragraph
C++ knows nothing about paragraphs -- only lines that are terminated by '\n' character. If you want to recognize paragraphcs then you will have to devise your own algorithm to do that.

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

you can export the entire class. I don't know if you can export boost library classes like this or not:

_dllspec(_dllexport) class A
{
// blabla
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>@Ancient Dragon: You probably mean memory manager as the compiler has no control over dynamic memory.

Depends -- memory management is a multi-terr operation. At the lowest level is the operating system that manages system-wide memory. Then you have the program's memory manager that manages all memory that is requested by new or malloc() functions. The program's memory manager, not the os, requests large chuncks of memory from the os and then diveys it out a little at a time to the program via the new and malloc() functions. When delete or free() is called the memory is kept by the program's memory manager and put into a free list so that it can quickly allocate it again.

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

you probably trashed memory somewhere else before that line was executed. Most likely cause is writing beyone the bounds of a buffer, but there could be lots of other reasons too.

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

1) limits.h has CHAR_BIT that defines the number of bits in a byte for your machine. Just find the file size and multiply by CHAR_BIT.

2) This wants two answers -- convert KB to bytes by multiplying by 1024, then divide that answer by the number bytes per second to get the answer.

3) simple 4th grade math problem that you should be able to figure out with pencil & paper.

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

its totally up to the compiler whether it honors the inline keyword or not, and there is no way to force the compiler to do it one way or the other, except maybe make the inline code a macro.

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

no

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

we have no way (in most cases that is) of controling where or how new allocates memory. Its purely up to each compiler how it wants to do it. One way is for the compiler to search its linked list of free memory blocks and return the smallest block that is at least as big as the amount of memory requested. Therefore memory blocks returned by new may or may not be adjacent, depending on other allocations/deallocations that took place.

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

you can not treat that array like a normal null-terminated string, because it isn't. If you do get the output you want then it will be only by pure accident.

But I ran your program with VC++ 2008 Express and got the output you wanted, luckly. I had to add a line to main(). Since the string is not null-terminated it could just as easily have printed a lot of garbage after thse 16 '0's.

char sk[4][4];
double _stdcall Decrypt_Text(int key_decrypt)
{
     for ( int j=0; j<4; j++)
     for (int i=0; i < 4; i++)	
       sk[i][j] = '0';
     return 0.0;
}

const char * _stdcall DisplayKey()
{      return ((const char *)sk);
}

int main()
{
    Decrypt_Text(0);
    const char * yy = DisplayKey();
     cout<<yy << "\n";	
     return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

One thing is for sure, the native Americans did not invent the nuclear bomb. Does that make them intellectually inferior?

If it did then the Germans are the most intelligent people on earth because they invented nuclear fision. And Einstein was a product of Germany.

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

depends on what addressType is defined to be.

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

Here is the output using VC++ 2008 Express on Vista. Is this the same as what you got? I'm sure the answers to your questions is how your compiler aligns data, on 1, 2, 4, 8 or 16 byte boundries.

Here comes all the address listings:
variable a: 26fe00
variable b: 26fdf4
memory location alloted to int b: 943f90
variable ver1: 26fde8
memory location alloted to struct ver1, known by its members: 943fc0 943fc4 943f
c8
memory location alloted to struct ver1, known directly : 943fc0
Memory location alloted to member tempmemcheck of struct ver1: 941258
variable ver2: 26fddc
memory location alloted to struct ver2, known by its members: 941288 94128c 9412
90
memory location alloted to struct ver2, known directly : 941288
Memory location alloted to member tempmemcheck of struct ver2: 9412c0
Press any key to continue . . .

agrawalashishku commented: Thanks you. That was very helpful +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>This could lead in deep discussion about who is made a first gunpowder
No deep thought needed to answer that -- the Chinese invented gunpower.

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

put the loop around lines 25-27.

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

Feet and inches should be integers, not doubles because they have no fractional parts. To get centimeters convert feet to inches before doing the calculations

centimeters = ((feet * 12) + inches) * 2.54.

meters = centimeters / 100.0

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

line 36 of your program: Please read this thread how to flush the input stream because fflush() is only for output streams.

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

Confused ??? :-/

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

What are you using for the gui program? OpenGL, DirectX, Direct Draw, QT, or something else? This is very very complex programming, so I hope you have a sound foundation in C and/or C++ programming because you will need it.

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

>>But i please say me can i iterate between characters in a string line.
Considering the format of the data file that statement makes no sense at all.

>>But I want to learn how I can get these as string line and save the values in numeric array.

So you want to read the data one line at a time into a string, then split the string into individual words so that they can be converted to numberic and put into an array ??

use fgets() to read each line then strtok() to extract the individual numbers (words)

char line[255];
float array[255] = {0};
int i = 0;
while( fgets(line, sizeof(line), fp) != NULL)
{
     char *ptr = strtok(line," ");
     while( ptr != NULL)
     {
           array[i] = atof(ptr);
           i++;
           ptr = strtok(NULL, " ");
      }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>6 ^ 1 = 6X6? = 36 (IS THAT CORRECT??)
No, that is not corrtect. 6 ^ 2 is 6 x 6.
6 ^ 1 = 6

you can use a calculator to verify the math

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

check to see if openPlaintext was actually opened

if( !openPlaintext.is_open() )
{
   cout << "Error";
}

Otherwise, post the file contents. You are opening the file in binary mode so I would expect the file to contain unreadable stuff. Open it in Notepad and see if you get the same sort of thing.

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

>>centimeters = (inches_per_foot * 2.5400);
To convert feet to centimeters feet * 30.48

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

Welcome to DaniWeb -- see you around :)

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

>>I am not getting the results
Not supprised because you can't return the array like that because it will disappear as soon as the function returns. There are a couple of ways to solve that problem:

1) add a parameter and have the calling program pass the input buffer

const char * _stdcall DisplayCipherText(char plaintext[16])
{
	ifstream openPlaintext ("Ciphertext.txt", ios::binary);
	openPlaintext.read(plaintext,16);
	return (plaintext);
}

int main()
{
   char plaintext[16];
const char * rt;
rt = DisplayCipherText(plaintext);
cout<<rt;
return 0;
}

Or allocate the buffer

const char * _stdcall DisplayCipherText()
{
    ifstream openPlaintext ("Ciphertext.txt", ios::binary);
    char* plaintext = new char[16];
    openPlaintext.read(plaintext,16);
    return (plaintext);
}

int main()
{
const char * rt;
rt = DisplayCipherText();
cout<<rt;
delete[] rt;
return 0;
}

If you want to allocate space for any size file then call seekg() to move the file pointer to end of file and tellg() to get current position -- that will give you the file size.

kartouss commented: Just brilliant and very helpful +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Simple -- you already have the ranges declared as integers or floats in lines 84-94, now all you have to do is read their values from the input file. You don't have to change another thing. Do that right after line 103 in the post above and it should work correctly.

nelledawg commented: Always extremely helpful! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I went back and reread this entire thread and no where have you ever told us what the actual file looks like. It will help if you post a line or two from the file so that we know what your program need to read.

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

we have no commercial adverts on BBC, so we get mostly uninterrupted viewing, but we have to pay for a TV licence to watch TV :(

Yes I found that out when I went to the UK for 3 years in the 70s. BBC was great -- but you still had other channels that had commercials. We have commercialess movie cable/sattalite channels. We get one called BBC America which shows old BBC programs with commercials.

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

wow ancient, you sound depressed

TV is lousy right now :@ Nothing but old reruns.

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

<deleted by AD>

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

I agree with Dani. I never heard of Moneybookers either. Just the name sounds a little slizzy to me.

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

>>Administrators , Moderators and all others who have a relationship have no right to answer .

Ok -- stop me :) Don't know if they get any of the jobs or not since most people probably deal directly with the company offering the jobs rather then posting in DaniWeb.

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

do you know how to create a structure ? Not much to them

struct <struct name>
{
   string name;
   int score;
}

Now just create an array of those things just like you did with the int array on line 37.

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

A prof said in a marketing class I took a looooong time ago that people remember only the 1st and last commercials. All the other commecials never stop between the ears. And I recall counting commercials -- there were nearly 20 commercials shown at one time during a late night movie. About 5 or 6 minutes of movie then 15-20 commercials.

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

>>for (y = 0, x = 0; y <= i; y++)

should be < operator, not <= because array values range from 0 to, but not including, i

Also, initialize arrays with 0 when declared to insure they do not contain random data arr[50] = {0}; In that same function x should be initialized to arr[0], not 0. for (y = 1, x = arr[0]; y < i; y++) >>else if (arr[y] > x)
>> x = arr[y];

Delete those two lines -- that function is supposed to find the smallest number, not the largest.

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

Don't you need an iterator for that loop

string MemorySlice;
    for( string::iterator i = MemorySlice.begin(); i != MemorySlice.end(); i++)
    {
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what is MemorySlice ? An iterator? And what does begin() and end() return?

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

One very common problem I had with porting from 6.0 was the use of loop counters, for example:

for(int i = 0; i < something; i++)
   // do something

if( i == 0 ) // ok on VC++ 6.0 but not in C++ standards or VC++ 2005/8/9

MFC has a ton of incompatabilities because may of its classes were converted to use templates.

How to correct: Take the errors one as a time and make them conform to the requirements of your current compiler and c++ standard. There is no quick fix -- just fix them one at a time.

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

I think your edition of the compiler supports MFC (Microsoft Foundation Class). You have two choices: 1) pure win32 api functions as shown in that tutorial, or 2) MFC. Your compiler's IDE has a wizard that will generate all the code for a basic SDI or MDI MFC program with menu in just a few seconds. After creating that just change it to however you want.

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

The instructions posted say nothing about coding the implementation of that class. Only need to declare the class.

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

horrified? Not at all. I love to watch all those commercials :) I think its great when there is 5 minutes of TV show and 10 minutes of commercials. Damed TV stations interrupting the commercials with all those tv shows.

>>GDP of Afghanistan was $35 billion.
Even more shocking is that Bill Gates himself has more money than that, and he is only the 3d richest man in the world, there are two others with even more money.

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

Looks like the only thing you do not have is the default constructor. That is a constructor with no parameters.

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

This is c++ so use std::vector class. Its an array that auto expands to hold however may items you want to put into it.

#include <vector>
using std::vector

int main()
{
    vector<int> ary;
    // add an int to the array
    ary.push_back(1234);
   // add another integer
   int number = 234;
   ay.push_back(number);

}

But I don't see a requirement for you to put all the numbers in an array. Just store them in a data file and be able to read them back. The instructions you posted say nothing about how the numbers are to be stored when read back. Maybe all you have to do is print them on the screen as they are read from the file. In that case they don't have to be stored anywhere.

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

>>BTW do you believe that philosophy knowledge is worthless ?
Most of it, yes. Also phychology, at least what's taught in Psych 101 classes.

>>I am having a problem with writing English I get miss understand
I see that. Just don't ask me to write in your language because I would be terrible at it. Just like anything else the more you practice the better you will get at it.

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

Ohh did you catch the picture of Richard Simmons at the bottom :) :) He might seem a little wierd but got to give the guy a lot of credit for losing all that blubber. His before and after pictures are here.