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

you should first create an empty project then copy the source files that you have into the project directory and finally add the files to the project. If you are using VC++ 2008 Express: read and watch this tutorial

If you really have zero knowledge of C language then I'd suggest you take a look at some online tutorials or read a book. There are many suggestions in the Read Me threads at the top of the C++ board.

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

>> ideas ?

Yes, here is one solution

int main()
{
    char line[] = "333 hou 23se 444 bi 4g";
    char buf[100] = {0};
    char *p1 = line;
    char *p2 = buf;
    while( *p1 )
    {
        // use temp pointer to locate
        // end of digits
        char* p3 = p1;
        while( isdigit(*p3) )
            p3++;
        // is there a space following the digits ?
        if( *p3 == ' ')
            // yes, then skip the space and move on to the next char
            p1 = p3+1;
        else
        {
            // no, then was the last char put into temp buffer
            // a space
            if( *(p2-1) == ' ')
                // yes, then overwrite that space with a new character
                p2--;
            p1 = p3;
        }
        // copy all characters up to the next digit
        while(*p1 && !isdigit(*p1) )
            *p2++ = *p1++;
    }

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

lines 18 and 19. Why do you want to overwrite the last character read by '\n'? Don't you want to append it to the end of the string instead of overwriting the last character ? Actually I don't know why you want to do that anyway -- we normally just delete the '\n' if it exists.

line 20: useless line. record is already the full line that was read from the file. There is no reason to call strtok() for that.

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

Its a lot simplier in c++

ifstream in("myfile");
int n;
in >> n;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I don't quite know "what to return" from this block of code
It means that function must return something. You need to add return input; on line 29 or the first code you posted.

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

>>how do I concantinate the filename?
strcat(FilePath,"Filename");

or

strcat(FilePath,"\\Filename");

depending on if getcwd() terminates the path with '\' or not.

CodeBoy101 commented: Perfect!! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

can you please show me how to do one of the two PLEASE?

Sure -- here is the first line

for(int i = 0; i < 15; i++) // number of spaces to display
  cout << ' '; // display one space
cout << '*';  // finally display the asterisk

you can also do it using C functions

char line[126];
sprintf(line,"%15.15s", "*");
cout << line;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To do the second one just print spaces before the stars.

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

>>2-4 are just reflections/rotations of the first one
That tells us nothing.

>>please help with the other 2
And you can't count either because 4 - 1 != 2 :)

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

>>stat = canWrite(hnd, 1234, size, 8, canMSG_EXT);
what is the 1234 and 8 for? sizeof(size_t), which is an unsigned int, if 4 on most 32-bit computers, not 8.

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

That leads me to think that the program is not running in the same shall as you were when you tested echo $HISTFILE from the command line.

I don't remember how to run a program in the same shell. *nix is not my os and its been several years since I've used it.

c++noobie commented: Ancient Dragon was very helpful +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 11: make input a char* char* input std::string crashes when attempting to assign it a NULL

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

post code exactly as you tried to compile it.

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

>>It dropped and I received a segmentation fault.
Try this one instead

input = getenv("HISTFILE");
if( input == NULL)
   cout << "input is NULL\n";
else
   cout << input << "\n";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 17: that will only work if there are no spaces in the path or filename. The shell treats the words seperated by spaces as seperate arguments

Put a print statement after getenv("HISTFILE") to see if it returns NULL or not. Print out its value if it doesn't return NULL.

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

do you know if $HISTFILE actually exists in the environment ? My guess is that getenv() returns NULL and your program is not checking for a NULL return.

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

>>That's for remote accessing a computer is it not?

>>I'm only looking for a solution that allows for editing of web pages directly
>>By this I mean so a client can say click on a hotspot, log in and amend the content of a page
You have to do that on the client's computer. I guess you could do the actualy work on your local computer then use PcAnywhere to log into the client's computer and transfer the file(s) there. Unless the client has a way setup so that you can log onto his computer via web url. Then you could upload the file(s) to his computer via web.

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

Here are some examples

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

The values are 0 because its doing integer math. 1/2 is 0 and the remainder is tossed into the bit bucket. If you want remainders than make the array float instead of int.

>> it is suppose to take any number that is less than zero and make it negative. However, the output file results show the results are always positive.

Simple algebra -- a negative negative is a positive. So -(-1) is +1. You must have read that requirement incorrectly because if you make a number less than 0 it is already negative. number[i] = -number[i]; //converts a number less than 0 to a negative value That creates a positive number, not a negative number. If number < 0 then its already negative, so you don't have to do anything to it.

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

how about using something like PcAnywhere or Hummingbird ?

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

Use windows explorer to check the location of the input file -- it probably isn't in the folder you think it is. If no path is given the file must be in the same folder as the executable program. And the output file will also be written to the same folder that the executable is in.

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

>> number = (number/interface_speed)/hop_value;
Depending on the value of number that formula may result in 0

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

>>integers are to be written with eight rows and eight columns
I stopped the loop after it wrong over 1,000,000 data items. It was due mainly to that while loop because it was an infinite loop. The code I posted writes 6 numbers to a line, you can easily change that if you wish to however many you want by changing the line with the % operator.

Please re-read my previous post because I added a correction to write . There is the output

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

line 59: If the file contains 6 X 6 = 36 number of integers why is matrix_size defined as 64? The loop starting on line 59 will process array elements 37-64 which have not been initialized with anything and just contain some random values.

void create_matrix(int number[]) 
{
  ofstream fout;
  fout.open("data.txt"); //opens an output file
 
 //this set of code is to write the data to the output file
 //after is writes 6 numbers  it is to go to the next line and write 6 more
 // numbers and continue to do this until it is done
  
   for(int i =0; i < matrix_size; i++)
   {
       if( (i % 6) == 0)
           fout << "\n";
       fout<<number[i]<< '\t';
   }
   cout << "\n";
   fout.close(); //close output file
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The code I suggested does nothing to the size of the file because it only reads the file, not write it.


line 64: >> number = number[-i];
-i is an illegal index into the array. what you meant is number[i] = -number[i]; The problem with creating such a huge file is located at lines 84-89. That is writing the same values matrix_size * nodes number of times, or 8^3 number of times.

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

4/3 is integer math to get floating point math to 4.0/3.0

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

line 31: that is calling GetRadius() ok but throwing away its return value. flat radius = Sweet.GetRadius(); Other similar lines have the same problem.

line 45: endl only works with cout.

lines 54 and 68: those functions must return some value even if it fails the validation. return 0 would be an appropriate value to return.

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

first call getcwd() or _getcwd() to get the current path then concantinate the filename.

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

see my comment about line 9. Initializing the array to 0 will fix that. Also make sure you have read all the other comments because I may have added some since you last read it.

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

line 8: should be const int capacity line 9: you need to initialize all the bytes of the array with 0 so that they contain a known value char letter[capacity] = {0}; line 17: >>char letter[] = {A};
That is incorrect -- shold probably be letter[pax] = 'A'; What it should be doing is inserting the letter 'A' into the character array letter (which was declared earlier line line 9) at position pax.

line 38: should be cout << letter<< endl; because letter[capacity] is one character beyone the end of the array.

line 12: Is there some reason to hard-code the value of y to 6? Instead of getting its value from the keyboard ? With that hard-coded value it never changes so why have that loop with checks for all those values of y when there can only be one value ?

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

lines 55-59 -- that is the wrong way to code such a loop. See the way I showed it in my previous post. It will not work the way you have it if end-of-file is reached before matrix_size number of characters.

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

>>I didn't figure out if it's possible to create 32 bit pointers in a DOS application
Yes, it is possible, depending on the memory model. use the FAR keyword to create 32-bit pointers in small memory model. 32-bit pointers are default in the large memory model. But that still can't address memory above the 1 meg limit.

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

how big is number ? Is array_size the number of valid elements in the array? If that is true then line 9 is wrong because there is no such element as number[array_size] -- should be number[array_size-1]

why is that reading the file one character at a time? The >> will skip all white space (spaces and tab characters). Why not something like this:

int index = 0;
while(index < array_size && fin >> number[index] )
  index++;

The above will read the entire file until either end-of-file or the max number of elements in the array is reached.

line 39: >> void create_matrix(int &number)
That's wrong. number is an array of integers and what you have there is a reference to a single integer. You want this: void create_matrix(int number[])

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

>>Please understand, the world will not end.
Sorry to disappoint you but all scientists agree that our sun will become supernova one day. I think that will turn the Earth into a cinder ball.

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

depends on what addressType is defined to be.

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

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

>>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

>>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

>>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

line 4: put all includes at the top of the file before anything else. It might compile the way you have it but its not the standard practice to put includes inside functions like that.

As for your actual problem -- don't know.

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

In your example just fill in the missing elements with 0 to make both arrays the same size, then do like vmanes mentioned, assuming that's what his teacher wants. And that would explain the need for two loops.

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

>>so I do not know what they are going to be.
Count them as the user enters the numbers. Each time you enter a number increment the counter by 1.

>>you will need to use at least 2 for loops to add the two arrays together,
If array A contains 10 numbers and array B contains 7 numbers, then the first loop counts from 0 to 7 and the second loop only counts from 7 to 10 to get the numbers that are in A but not in B.

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

If you mean matrix algegra then the two arrays have to be the same size.

But lets say you have two arrays

int A[] = {1,2,3,4,5};
int B[] = {2,3,4,5,6};

then array C[0] = A[0] + B[0], and C[1] = A[1] + B[1], etc.

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

2012 is the year london is supposed to hold the olympics, but nothing is built yet.

Why should you brits waste your money on something that won't (can't) happen? There's no point building something that will just get destroyed before you can use it.

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

>>So i rather do not think about anything
So your mind is totally void of any thought :)

>>I would like to exist some organization who kills people who do not like to live because I did not ask anyone for life .(
Actually there are a few who do that. If you are looking for someone to kill you I'm sure we can accommodate you.

>>I did not live before 1986 so ,I can said that hole world is set up because of me . And created just before that time

Oh I see -- The universe and everything in it did not exist before you were born. Is that what classes in Philosophy does to students minds ? I'm glad I avoided them :)

>>The scientist said about intelligence but I do not trust them why should I when they are
>>all human with greed .And I do not trust even in the church why should I ? I trust in my
>>act only . Not even my parents I always check what they are puts in my food

OMG are you really paranoid! Do parents often poison their children in your country ?

>>So today normal people can said that I am a mad man and I need to go into madhouse
Sounds like an accurate assessment to me.

>>Look at this , when you are a poor you want to get rich

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

since its binary data it will be better to read it into unsigned char array. There is one way to do it.

unsigned char* buf = 0;
size_t filesize = 0;
FILE* fp = fopen("sound.mp3","rb");
// get the size of the file and allocate input buffer space
fseek(fp,0,SEEK_END); 
filesize = ftell(fp);
// go back to beginning of file
fseek(fp,0,SEEK_SET);
// allocate input buffer
buf = malloc(filesize);
// read into buffer
fread(buf,1,filesize,fp);
fclose(fp);