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

Huh whats going on ?

If you don't watch american baseball or bootball you may not understand. Its the number of somethings needed to achieve some goal -- in the case of baseball its the number of games a team needs to win to be in the league playoffs.

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

Bill & Milenda Gates Foundation, like the Rockefeller Foundation, is a corporation set up to do nothing but give money away and to make the world a better place for all of us to live in. People who are filthy rich like that have an obligation to use their welth for the betterment of mankind. And I think both Gates and Rockefellers are doing their fair share.

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

are you asking for a program that will send out spam text messages ? If so I doubt you will find it on DaniWeb.

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

do it just like you would from the command line.

system("dir > myfile.txt");
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Please post entire function and complete error message including line number -- we still have no clude how ADDR_GODMODE is declared or what line number that error occurred.

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

for a beginner, get the free VB.NET Express edition.

>>what is the diffrence between vb.net and visual basic language can u please tell me
Nothing, the are one and the same. vb is an abbreviation for "visual basic". .net is the newest version.

>>what is the diffrence between vb.net and visual basic language can u please tell me
you should post that question in the Web Development board. There are a lot of languages that allow you to create web sites that are superior to VB. I'm no expert at that, so post on the Web Development board if you want expert advice.

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

If you want someone to review your website, please post your request here.

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

My magic number is now 3 :mrgreen:

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

The reason me and Vishesh call you Mr. is because it has a different meaning in our country. Here we use the title Sir or Mr. to a person who is more knowledgable than us or as a means of giving respect.:

That applies here too for children -- parents teach (or should) children to respect their elders. But after children grow into adulthood they normally drop the Mr because they are considered to be at nearly the same level.

>>Diablo - Lord of Terror
Greate game from Blizzard -- that is where I picked up my handle about 10 years ago. I still play it often.

>Approved !! BTW the newbies would be in a bit of shock when I start calling you and Mr. WaltP "Sir"
as long as its something like "Sir Dragon" and not "Mr Dragon Sir". "Sir Dragon" shounds more royal. :cheesy:

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

I fail to understand what is the logic behind this...:!

People who are called Mr. usually are the CEO or a company or a manager or supervisor who are preceived by many employees as doing nothing. Afterall, it is the employees that do all the work, while supervisors just stand around watching.

>> BTW how about Sir Dragon
That one I like :mrgreen: :mrgreen: :mrgreen:

>Naa you are not evil
you didn't see the one I had for a couple hours yesterday did you?

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

The function is reduced to this:

int function(int val)
{
    return (val * 5);
}

why? because of the associative (?) properties of mathametics

val * 4 + val
is the same as
val + val + val + val + val; // there are 5 vals on this line

val * 6 - val;
is the same as this
val + val + val + val + val + val - val;
which is
val + val + val + val + val; // there are also 5 vals on this line

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

Ok, tried this

int longest(void)

{
	char line[BUFSIZE] = {'\0'} ;
	int counter=0;
	int longest=0;
	char fname[128];
	FILE *file;
	
	file=fopen(fname,"r");
	
	

    while (fgets( line, BUFSIZE, file )!=0)
	{
	 
	 counter=strlen(line);
	

	 if(counter>longest)

		{
		 longest=counter;
		}
   
	}
	return longest; 

}

I'm getting a Debug assertion failed with fgets.c.Seriously, wouldn't it be easier to use something other fgets()? (Just asking don't crucify me)

The debug assertion error fails because the file pointer is NULL, not because fgets() does not work. fname[] is an unitiailzied string which will cause fopen() to return NULL instead of a valid pointer to the FILE object. Your program should check for a vaid fopen() return value.

file=fopen(fname,"r");
                if( file == NULL)
                {
                   // display an error and terminate the program
                 }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> while ((c = fprintf(file,"%c",&c)) != EOF)

Please, stop coding if you know nothing about what you are doing. At least look up the functions before you indiscriminately toss at your program like darts at a dartboard.

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

>>Excuse my crappy English, I'm Dutch
Your english is a lot better than my dutch:eek:

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

until counter = all chars in file?

on MS-Windows os it will not be the same as the file size because it does not include one of the two line terminating character(s). To get the file size add one to counter for each line read except the last line. The last line may or may not contain '\n', so the program has to check the last character to see if it should also account for the '\r' character.

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

Please note that " 0 " is not the same as " NULL "

Regards Niek

On recent compiler, yes it is. NULL is just a define which is defined as 0

#define NULL 0

on many very old compilers NULL may also be defined as (char*)0.

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

>>Yeah I'm using c style strings in c++ code get over it
that is ok if you have not yet learned about std::string or your instructor requires character arrays.

The function causes buss error probably because it does not return the stream. Your compiler should have given you either an error or a warning about that. Do not overlook warnings because they are often errors.

>>char mystring[16];
too small. you forgot to make room for the null terminator

>>Normally I wouldn't bother about something that could be fixed by coding seperate lines instead of putting it all in one
That would fix nothing because the compiler could care less.

What happens if you type in an ip with incorrect format? strtok() will return NULL at some point and the operator>> method will crash.

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

now Mr. Dragon, please help me with my own avatar...:)

Please, Please drop the "Mr." Someone told me once a long long time ago "I'm not a Mr. -- I have to work for a living".

What do you want to be known as -- I really don't know much about you because your public profile tells us nothing.

Getting late now for me anyway -- 10:30 p.m. and have to get up at 6:30 a.m. Talk more tomaroow if you wish.

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

Ok, I changed it again. Better ???

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

BTW Mr. Dragon, your second avatar, the Dragon revamped was much better, it suited you more. :cheesy:

You mean you liked that evil dragon? I don't think it suits me at all. I may be cranky and absent-minded at times, but never evil.

They must be thinking that the person with I think Bam Bam as an avatar would be a 12 year old kid and then would get shocked seeing that this 12 year kid was a moderator.

Wait til they read my profile and find out hold young I really am :eek:

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

I agree

He must get something like mine, something really cool:mrgreen:....although i'll change my avatar soon.
From where u got this...

I had an avatar for a couple hours that looked like a very evil dragon -- but I don't want to be known as someone who is evil, so looked for something a lot more suitable for this forum. After searching the web for a couple hours I decided BamBam seemed appropriate. He doesn't look like a dragon, thats true, but he has one as a pet:)

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

>>I read the complete line using getline then I am not able to ignore the lines with word pattern.

Its not possible anyway, so what's the problem with that. If a line that contains the text "pattern" is read, then just ignore it and read another line. I already posted example of how to handle that, and I am not going to repeat what I already posted.

what is the difference between a line that starts with "SAF" and "CLB" ?

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

The '\' character is called an escape character in c and c++ languages. If you want a literal '\' you have to use two of them, like this:

LPCTSTR regPath = "SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ActiveComputerName";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> while ((fgets( line, BUFSIZE, file )!=EOF))//why shoudn't I use EOF is there something better?

You really should learn to read the documentation about the functions that you use. If you had, you would have found out that fgets() returns a char pointer or NULL when end-of-file is reached. Don't just toss functions at a program without knowning what they do. you can google for most fiunctions, such as "man fgets" will return the man page for that function.

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

I already gave you an outline of how to write the program. Maybe you ignored it, or maybe you did not understand it?

if you use if - else if - statements it will be ok. Below will first check if "heading" is in the line, if not it will check if "value" is in the line.

if( line.find("heading") != string::npos)
{
   // heading found
}
else if( line.find("value") != string::npos)
{
   .// value found
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Any idea how to do the length of the input buffer? I'm really green with this.

length was the wrong word to use. size is what it wants, in your case it will be 1024.

DWORD size1 = sizeof(rgValue);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>ok i changed that to match and now its giving me some more issues heres my code

what where the errors? did you make any attempt to fix them?

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

That's exactly what I did, except I declared "k" as a global too. The problem is that the user may choose enter a char for whatever reason, and if they do, it gets screwed. I don't want that to happen.

which is why it is probably better to get keyboard input as a string so that you can parse the string to see if it contains any invalid characters (in your case any non-numeric digits). If it does, then display an error message and make them re-enter it. cin will not do that for you.

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

Alternatively if you expect everything as a string, you don't need to clear nuffin.

And just convert to double or int where you need to. Works every time.

which is the soluition I original posted. But I like to find new ways of doing something -- learn something new every day will keep the doctor away. :cheesy:

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

Dont you think you are forgetting something... as in what to ignore.:cheesy:

AhHa! That's it. :cheesy:

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

variable size1 must be set to the length of the input buffer, 1024 in your example. you might also initialize rgValue to 0

char rgValue [1024] = {0};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I never can remember the whole thing without refering to my cheat sheet, which I don't have with me.

std::cin.ignore(std::numeric_limits<streamsize>::max());

See if removing the angled bracket before numeric_limits does the trick. Oh, you also need to include the limits and, I believe, the ios header files for it to work. BTW, the first person I saw use this syntax is a distinguished poster here. If I still don't have it correct, maybe she will assist.

As you can see from my previous two posts I figured out the syntax error problem. who is this "distinguished poster" ?

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

Try putting cin.clear( ) before the cin.ignore( ) stmt and see if it works...

I did and it doesn't. New code below

#include <iostream>
#include <limits>
using namespace std;

int main(int argc, char* argv[])
{
	int a;
	cout << "enter something ...";
	cin >> a;
	cout << "you entered " << a << endl;
	std::cin.clear();
// never gets past the next line 
	std::cin.ignore(std::numeric_limits<streamsize>::max());
	cout << "\nenter something else";
	cin >> a;
	cout << "a = " << a << endl;

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

>> std::cin.ignore(std::<numeric_limits<streamsize>::max());
illegal syntax at '<' character. But otherwise interesting way to clear the keyboard buffer, just please post a corrected version. Too bad it doesn't work. In the example below, enter 123al;skfjlsdkf <Enter> The keyboard buffer is not cleared.

#include <iostream>
#include <limits>
using namespace std;

int main(int argc, char* argv[])
{
	int a;
	cout << "enter something ...";
	cin >> a;
   std::cin.ignore(std::numeric_limits<streamsize>::max());
   cout << "\nenter something else";
   cin >> a;
   cout << "a = " << a << endl;

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

I know....
that's why I said:

:p

Regards, Niek

Oops!:o

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

does the last line of the file contain '\n' ? If not, then your program will not count it. fgets() will fix that problem because it reads all lines. Getting the length of the longest line is trivel too -- just use strlen() to get the length of the line read by fgets().

The size of the file can not be determined by either your program or using fgets() becuase in MS-Windows os reading text files converts "\r\n" into just "\n". It will be easier to get file length by calling fstat() or stat().

file=fopen("summaryData.txt","w");
			 fputs("avgchar",file);

you forgot to close the file after writing to it. This will cause your program to eventually run out of file handles. And the fputs() statement is probably incorrect -- all it is doing is printing the same hard-coded text "avgchar" in the file each time. Use something like this:

fprintf(file,"%d\n", avgchar);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>but the stats are incorrect
how do you know that? What are you comparing them to?

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

Send me a link and I'll see what I can do

p.s. You could download VS2005 pro yourself from microsoft.com, it's a 90 day trail

The free express edition will not compile for wireless smart devices.

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

those functions sort double arrays, not int arrays. Either change your int arrays to double, or change the functions to sort int arrays. The two can not be mixed.

>>double sortArray(double [], int);
this is the wrong prototype. Actual function does not have those parameters.

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

did you read this tutorial

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

I think I can skip 1 for now. I coded 2 but I think I put it with section.h when it may need to go in section.cpp at the bottom as a single function. Also, not sure how to read in the scores and store them in an array. Do I need to create a separate file for these functions like testSection.cpp or they go in section.cpp(main) or section.h?

class declaration does in .h file -- no executable code other than inline code goes in the header file. That means you have to remove void Section::readData() from section.h.

section.cpp should only contain the implementation code for the methods that are in section.h file. main() should not be in that file, but for now I suppose it is ok to leave it there. Ultimately you will want main() in some other cpp file, such as main.cpp

>>I think I can skip 1 for now.
NO. do not skip any of the requirements. Do them in the order that they are stated.

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

>>provide the following member functions in your class:
does your class contain all 9 required methods ? If not then you need to code them as described in the program requirements. Just start with #1 and code each one in order. You should also test each method after coding it to insure that it works correctly. Do not wait until after you coded all of them because that will just make debugging efforts more difficult.

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


:cheesy: :cheesy: :cheesy: no such thing as winter here ..
iiiiiiii haaaaaaaaaaaaaate summer ..

rain is all i like :cool:

I think I'll take my tornados over those piles of sand, thank you. Right now we are in Fall when it rains often. Its been raining for the past three days. 500 miles to the north of us they have snow this time of year, but we won't get any until January.

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

In fact, the code which you posted will, in all cases, return 0, because:
rem = num - ((num/den)*den)
rem = num - (num*(den/den))
rem = num - (num*1)
rem = num - num
rem = 0 in all cases

mathematically you are right, but it doesn't work that way in a computer programs which do integer division. Look at the example I posted where num = 7 and den = 2. The result is not 0. (7/2)*2) == 3 * 2 == 6. Remainders are always discarded, there is no rounding.

The function posted in by the OP only indicates whether num is evenly divisible by den, and not whether it is a perfect number or not. The mod operator % will provide the same answer as that function.

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

if you do not specify "using namespace std" then you have to identify the namespace if it is not in global namespace.

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

use getline when the file name may or may not contain spaces.

int readData()
{
    std::string filename;
    cout << "Please enter in the path to the student score file: " << endl;

    getline(cin,filename);

        ifstream theFile(filename.c_str());

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

It is continuing like that because cin is trying to convert the alpha character that is in the keyboard buffer to numeric, but it fails and leaves the key in the keyboard buffer. The easiest way to correct this is to get the integer as a string the convert the string to int. Something like this will work:

do
{
  t=1;
   std::string input;
  cout << "\nEnter the encryption key (1-25): ";
  getline(cin,input);
  k = atol(input.c_str());
  if ((k<1)||(k>25))
  {
      cout << "\nERROR: Enter a valid number moron!\n";
      t=0;
  }
}
while (!t);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

please don't resurrect two year old threads. Thread closed.

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

pick any number and calculate it with pencil & paper. For example use 6 and 2.

6/2 = 3; --> (num/den)
3 * 2 = 6 --> ((num/den) * den)
rem = 6 - 6 == 0 --> rem = num - ((num/den)*den);

so 6 is a perfect number.

now try it with 7 and 2
7/2 = 3
3 * 2 = 6
rem = 7 - 6 == 1
so 7 is not a perfect number

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

open the log file for append mode, not write mode, if you want just one log file that contains info for all files
fopen(filename,"a");

or create a unique log file name if you want results in separate log files.