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

"I woot thee"
.

Sounds obscene :)

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

It's getting tough, Hillary just announced that she is willing to whipe all of Iran of the map.

I was contemplating selling my car so I could buy petrol for it. Now John McCain promisses to lower the price. I will vote for him!

Not if Iran wipes us off the map first :)

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

line 22: String is only declared as a single character -- it needs to be an array
char LowerCase(char String[]){

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

You probably need to read a pointer tutorial to find out what pointers are and how to use them.

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

The function ReverseString() is also incorrect. You need two counters there -- one that counts 0 to length and the other count down length to 0. Line 40 does nothing but copy the original string in the same order -- it does not reverse the string.

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

Your RemovePunct() only destroys the original string because strtok() inserts null bytes which renders the original string useless. You will first need to create another character array in which you can copy/concantinate the strings found by strtok(). Just mearly calling strtok() does not actually do anything but return a pointer to the beginning of the string that is terminated with one of those punctuation characters.

char tmpbuf[255] = {0};
char* New = strtok(String,",.-;!?");
while( New != NULL)
{
     strcat(tmpbuf,New);
     New = strtok(NULL,",.-;!?"); 
}
// now tmpbuf contains the final string without punctuation
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I doubt that your teacher would require you to write all the low-level gui functions yourself -- that would take even a professional several years to accomplish.

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

Two ways to do it that I can think of right off the top of my head
1) after reading the entire line, use std::string's find() method to locate the first comma then you will have the id field. Something like this

std::string line = "paciss0:abc,123,myoffice";
// locate the first comma
size_t pos = line.find(',');
// get the rest of the line
std::string id = line.substring(pos+1);
// remove everything after the 2nd command in the
// original string, leaving only id
pos = id.find(',');
id = id.substr(0,pos);

2) use std::stringstream with the line, then you can easily split it up using getline()

iamthwee commented: agreed +14
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> in fact i teach some languages
Your writing style, or rather lack of writing even one compresensible sentence, suggests otherwise. Unless of course your native language is not English.

>>i know c & c++ (of course not everthing in them...n i havnt reach graphics level)
graphics is not part of either c or c++ languages.

There are lots of threads here about writing game engines and you should probably read many of them to get an idea of what all is involved. This one, for example, seems to be an interesting discussion.

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

this compiles without errors or warnings on Dev-C++

int main()
{
char line[255];
float array[255] = {0};
int i = 0;
FILE* fp = fopen("myfile","r");
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

You can reverse a string in place by exchanging the characters at each end, working toward the middle. You do need a one char temporary holding spot as you do the three-way swap operation. You use separate index variables for each end, being sure to stop when you reach the mid-point.

Oh yea -- that's one reason you teach and I don't :)

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

I though about vmane's idea -- but you will need something much more complex than that. Simple comparison character by character might produce false matches

User-entered input: This is the user inpt
String stored in file: This and that

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

you might be able to use boost regex library. But don't ask me how to use it because I don't know.

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

do you know how to open a file and read each line? hint: ifstream and getline()

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

initialize it to 0 when you create the array of structures. Something like this

struct exam array[20];
for(int i = 0; i < 20; i++)
   array.total = 0;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>123 ?I dont understand...Ancient Dragon.

That was just a generic thing to mean any number -- whatever number you used in the push_back() function call.

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

If you have a choice of GUI then I would probably start with OpenGL because its free, portable and has a lot of support for questions etc.

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

OMG Everybody wants to program games :) Game developers are a dime a dozen, so unless you are very very exceptional developer you should do something else.

At any event, how much programming experience do you have? None: Then spend a few years learning the trade and maybe you will be good enough to get into game development. Until then you can start out by making very simple games such as tick-tack-toe or something like that. But the most important thing you have to do is learn one or more programming languages. c, c++ and probably java are the three most important languages you need to learn very very well.

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

knewc: line 20: you can't reverse the string using the same charcter array as the original string. You need to use a second array. That's the purpose of new_string. And use the = operator, not +=.

>>i could do this with my hands tied behind my back and plunk it out with my nose it's so easy. what a noob.
You was a newbe once too, so don't laugh too loudly.

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

you mean you want the structure to look like this:

struct exam
{
int examid;
float total;
};

You will have to make a lot of code changes to do that because total is no long an array of ints. I suppose instead of push_back(123) just add 123 to the current value of total.

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

To repeat John A

People who don't know how to use Google

I frequently find myself googling to find an answer -- the OP could have done that before making his/her post.

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

>>you admit it's a style point
Yes -- its pure style. They are both correct and we are only arguing about coding styles.

NULL only makes sense when used with pointers. But I've seen some people try to use it with integers, such as int x = NULL; . It works but its a misuse of NULL.

I do have to admit that there may be some obscure compilers that do NOT define NULL as (void *)0. The C standards do not dictate what value it has to be. There could be some operating systems which could define NULL as (void *)1234567. In that case coding 0 for NULL would be an error.

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

>>one is a character and the other is an integer
char is a one byte integer. C and C++ does not support pure character data type like VB and some other languages.

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

declare class Person first because it needs to be used in class Student class Student : public Person Next you need to code the implementation of the methods of both classes.

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

you have to put something before main() returns to stop it until you hit a key. There are several ways to do that but cin.get() is the most common in c++ programs.

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

npos is declared in <string> Look at the description of find() method and you will see that it returns npos when the string is not found.

For character arrays you can use strstr() declared in string.h Your text book should have the description for that function or you can look it up in google.

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

those warning could be safely ignored -- but to remove the warnings check the return value of strlen() -- it returns and size_t (an unsigned int), and you are attempting to compare it with an int. In the case of line 124 just change the data type of variable i to size_t

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

1) Sleep(60*1000); -- MS-Windows, *nix is the same except use sleep(60) instead of Sleep()

2) best to write the last time to some external file, such as the registry or a file, so that your program can continue to do other things during that lengthly time. Then once each hour check that registry entry or file to see if the time has expired.

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

I agree with Steven on that one -- You can be alone while surrounded by people. Sometimes alone = lonliness. And for Steven's statement we will probably be alone even though there may be billions of intelligent species because either a) there is no way for us to travel to them or them to us, or 2) there is no way for us to communicate with them, something like us trying to talk to an ant.

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

/* Define NULL pointer value */
#ifndef NULL
#ifdef __cplusplus
#define NULL 0 // <<< C++ language
#else
#define NULL ((void *)0) // <<< C language
#endif
#endif

In C language NULL is defined as 0 -- the above does nothing more than cast 0 to a pointer . There is no downgrading from int to char involved. 0 is still 0 by any other name. It might be defined somewhat differently by other compilers, such as 16-bit large memory model compiler might define it as NULL (char far *)0 , that that too is just another typecast of 0.

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

>>Is the only way to do this byte by byte with memcpy or setting up a for loop?
There is one other way that I can think of *(int *)&message[0] = number;

int main()
{
    unsigned char message[4];
    int number = 1234;
    *(int *)&message[0] = number;
    cout << *(int *)message << "\n";
    return 0;
}
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

you are doing integer math and you need to do floating point math

int a = 2;
int b = 3;
int c = 2;
float result = (float)(a+b+c)/3.0F