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

did you try google?

>>how do I pass a variable (named COM) from an app to the dll?
The same way that you would pass it to any other function.

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

Tucson, Arizona USA is my favorite where I have lived. It's hot and dry year around. NO SNOW :) :) The pictures in that link are from the surrounding desert, not the city itself.

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

>>Why is it that the samples on the MSDN Learning center cannot be compiled
Link please so we can check it out

>>With Itanium as the active solution platform by default
I don't have that option on my computer. Only win32. But I suppose you have to be running 64-bit version of the os in order to get it.

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

wxWidgets is also pretty popular alternative, and also free.

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

>>how can a file be of negative size
It can't. The problem is that your program contains one or more bugs.

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

Another method

char iobuf[] = "222   chris brown   50";
char* ptr;
// find beginning of name
while( !isalpha(*ptr))
   ptr++;
memmove(iobuf,ptr,strlen(ptr)+1);
// find end of name
ptr = iobuf + strlen(iobuf)-1;
while(!isalpha(*ptr))
    ptr--;
// truncate
*(ptr+1) = 0;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Since the name may or may not contain spaces you will have to
1) read the entire line into a character array. You can use fgets() to do that.

2) use a char pointer to advance from the beginning of the string to the beginning of the name. Copy all remaining characters into another character buffer.

3) in the new buffer from 2) above locate the end of the string, back up to the first space, then back up some more until there are no more characters. That will locate the end of the name. At that spot add a NULL character -- '\0'.

char iobuf[] = "222   chris brown   50";
char tbuf[40] = {0};
char* ptr;
// find the location of the first character in the name
//
// find the first space
ptr = iobuf;
while(*ptr && !isspace(*ptr) )
   ptr++;
// now find the first non-space
while(*ptr && isspace(*ptr))
   ptr++;
// ok, we're at the first letter of the name
// so copy remainder to new buffer
strcpy(tbuf,ptr);
// now locate end of string
ptr = tbuf + strlen(tbuf) - 1;

// back up to first space
while(!isspace(*ptr) )
   ptr--;
// back up to first non-space
while(isspace(*ptr) )
   ptr--;
// we're now at the end of the name.  So truncate the string
*(ptr+1) = 0;

// print the name
printf("%s\n", tbuf);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Can you use C to connect to SQL???
If you mean an SQL server -- the answer is an astounding/resounding YES. There are billions of C/C++ programs (ok so that's a bit of a stretch) that have done that. Just google for ODBC to see how to do it.

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

click here to see the problems with gets()

>>but then you have to press the keyboard twice in order to input data..
You could write your own keyboard input function that replaces gets() and uses only getch() to get the keys. Of course if you do that then you will also have to handle the other special keys, such as backspace, left/right arrows, del, etc.

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

Earth is not flat. its round in shape.

Sorry, but I heard its egg shapped.

[/edit]But these Nasa pictures clear show a round Earth.[/edit]

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

After reading the number you need to flush the remainder of the line. Read this Read Me thread to see how to do that.

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

must have been a fluke -- I can't duplicate that.

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

Well apparently you haven't posted the code that has the problem. No point in me looking at something that isn't current code. So, unless you post CURRENT code I'm not going to bother looking at it any more.

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

>>RoboExtract::askUser();
There's the problem. Only static methods can be accessed that way. askUser() is not static.

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

why does RoboExtract.h include itself? See the 4th line of RoboExtract.h that you posted.

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

you can use std::transform() to convert the strings to either upper or lower class then use the comparisons

std::string s1 = "Hello";
std::string s2 = "HELLO";

std::transform( s1,begin(),s1.end(),s1.begin(),touper);
std::transform( s2,begin(),s2.end(),s2.begin(),touper);
if(s1 == s2)
{
   // do something
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What does one do after becoming the greatest swimmer in Olympic history??? He could make TV commercials, but I'd think that would be pretty dull. His sponsor already gave him $1Million. Now what???

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

you need to clear the input stream of all the characters -- see the Read Me thread about how to do that.

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

jibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabberjibber jabber :) :) :)

scru commented: lol +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>if ((inputLetter >= 'A' || 'a') && (inputLetter <= 'Z' || 'z'))

You can't use the || operator like that. Here is how you have to do that if ((inputLetter >= 'A' && inputLetter <= 'Z') || (inputLetter >='a' && inputLetter <='z')) A better way is to convert the letter to upper case (or lower case) then do just one comparison

inputLetter = toupper(inputLetter);
if( toupper(inputLetter) )
{
   // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

AD's simplistic approach would only confirm that the number of writes matched the number of reads, but you could still have filled the file with zeros or garbage.

Agree -- the only true way to determine if the file was written correctly is to compare the two files. There are diff programs available that will do that -- compare two files and display their differences, if any.

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

That compiler does not support MFC. To get MFC you have to buy with your $$$ the standard or professional version. MFC and associated libraries are NOT free.

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

What version of Windows are you using? I think they all have an icon on the Start menu called Command Prompt. Goto Start --> Accessories, and you will find it on that menu.

When you get that window you will have to change directories to the location where your program's *.exe is located.

c:>cd <path goes here> <Enter key>
coveredinflies commented: Thanks :) +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

your lecture notes are wrong and so is your instructor.

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

For stats.getline(counter,200); It works without the for loop too. If I understand this correctly, the while (!stats.eof()) will help loop and get the data from the text file.
So why do I need another while loop?

Appreciate the help :)

You don't need another while loop -- just correct the while loop you already have. eof() doesn't work the way you think it does and will cause the loop to execute one too many times. Replact that with what I posted and the loop will work correctly.

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

I think you misunderstood what strlen() does -- it returns the number of characters in the buffer up to, but not including, the first byte that contains 0. That is normally smaller than the number of characters that the buffer can hold.

Example: char buffer[255] = "Hello"; In the above, strlen() will return 5.

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

first problem: the while statement is incorrect. Here is how to do it. while( stats.getline(counter,200) ) Why do you think strlen() doesn't work? Its been working correctly for millions of programmers all over the globe for over 25 years, so I doubt it has a bug.

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

command line arguments are entered into your program via main() function. it has two optional arguments int main(int argc, char* argv[]) argc == number of arguments and always > 0 because the name of the program is 1

argv == array of characters that contain the strings that you put on the command line, separated by spaces or tabs. argv[0] is always the name of the program.

So if you typed this on the command line your program would bet four arguments c:>myprog one two three <Enter> argv[0] = "myprog"
argv[1] = "one"
etc

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

>>I have used char *per because 'write' function only accepts pointer to character.
False. You can put anything you want to there -- just typecast it to char*


But you still failed to correct the problem. per is still an unallocated pointer which will crash your program.

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

1) most likely, but that would be implementation dependent, which means compilers can do it however they wish.

2) Neither. It advances to the next object in the vector, whatever that is.

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

The problem seems to be in this code snippet

else if (posfijo[i] != ' ' )
  { // else began
      y = numStack.top();
      numStack.pop();
      x = numStack.top();
      numStack.pop();

Apparently the stack is empty when top() is called.

How to fix it -- I don't know without doing a lot of debugging. That part I leave up to you to figure out how to do.

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

1) static is a scope operator that limits the scope of the function to the *.c file in which it is declared. If you have two *.c files, each file could contain a function with the same name as long as the function is declared static. IMO its poor programming to have two functions like that, but it is possible.

2) compile it and find out what happens.

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

1) what are the errors -- or do we have to guess???

2) you have two main() functions declared. One in the header, where it should NOT be.

3) void main() -- don't use it. main() ALWAYS returns an int. Click here. for more info about that.

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

you can also call standard C function fstat() or stat(), which will return error if the file is not found. And if it is found it will tell you how big it is -- you can use that info to compare with the original file to see if they are the same size.

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

That will most likely crash too. If it already is tx.end() then incrementing it again won't work. And you're using the post-increment operator which means the comparison is made before incrementing, and then you will have the exact problem that you have now.

Maybe what you want is this: for(it1 = it + 1; it1 != tx.end();

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

Press the Go Advance button, then scroll down near the bottom of the screen and you will see Manage Attachments. Hit that, then the browse button will let you find the file on your computer.

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

The problem is on line 46. The first time through where is only one number in the vector and iterator it is set to tx.end() because you incremented it on line 44.

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

>>The reason for my question was not getting the difference.
Ok, so what is it that you wanted to ask?

>>I would ask to the point in future....
Absolutely! you can't be vague around here because if you don't know what you want we sure won't either.

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

Call EnumWindows() to get a list of all the top-level windows so that you can get the handle to the browser window. The problem is -- how will you know which one is the browser?

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

depends on the error message. compile your program for debugging and find out what's causing the problem.

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

If you have learned about structures and classes yet it would be a lot easier on you if you created a structure or class to contain the data for one student, then read the data into an array of structures. The sort program then only has to sort one thing instead of 4 of 5.

struct student
{
    string lastname;
    string firstname;
    int studentID;
    float grades[cols];
};

struct student studentList[rows];

// sort
Sort(studentList[])
{
    for(int i = 0; i < rows-1; i++)
    {
         for(int j = i+1; j < rows; j++)
         {
               if( studentList[i] < studentList[j] )
               {
                    struct student temp = studentList[i];
                    studentList[i] = studentList[j];
                    studentList[j] = temp;
               }
          }
      }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't do MAC but I see two possibilities.
The data directory is directly off the root directory std::string add = "/data/scripts/"; or The data directory is a subdirectory of the current working directory. std::string add = "./data/scripts/";

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

your program is close, but close isn't good enough. The call to Sort() is in the wrong place -- only call it once after all the data file has been read. Also the use of some variables is inconsistent in the loop that reads the data file. I also made a slight change to the sort algorithm.

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>

using namespace std;

const int rows = 12;
const int cols = 8;

void HEADING();
void Sort (string [],string [],int [],float [][8]);
void AVERAGEDISPLAY(float average, float average2);
void displayarray(string [],string [],int [],float[][8], int);




int main()
{	
	ifstream inData;
	int names=0;
	string lastname[rows], firstname[rows];
    int studentID[rows] = {0};
	int i=0,j;						//for rows and cols
	float sum=0,total, total2=0;    //subject and score totals
    float studentgrades[rows][cols] = {0};
	float average=0,average2=0;		//average subject and score averages
	

	inData.open("..\\TextFile1.txt");
	
	HEADING();//display heading

	while (inData>>lastname[names]>>firstname[names]>>studentID[names])
	{
		cout<<lastname[names]<<" "<<firstname[names]<<" "<<studentID[names]<<" ";
		
            
			for (j=0; j<cols; j++)//loop for studentgrades
            { 
	         inData >> studentgrades[names][j];
	         cout<<fixed<<setprecision(1)<<setw(5)<<studentgrades[names][j]<<" ";
			 sum=sum+studentgrades[names][j];//adds subject grade for individual student
			
            }
			total2=sum/cols;//averages individual student grade
			cout<<setw(5)<<total2;
			average+=total2;//adds for average grade
			sum=0;
			names++;
			cout<<endl;		
	}
    Sort(lastname,firstname,studentID,studentgrades);	
		cout<<endl;
		cout<<"SUBJECT AVERAGES ARE:";
		
		for (j=0; j<cols; j++)//loop for subject averages
		{	total=0;
            for (i=0; i<rows; i++)
            { 
	         inData >> studentgrades[i][j];
			 total+=studentgrades[i][j];//adds subjects only
            }
			cout<<fixed<<setprecision(1)<<setw(5)<<total/rows<<" ";
			average2+=total/rows;//adds subject averages
		}


	AVERAGEDISPLAY(average, average2);//displays student and subject grade averages
	displayarray(lastname, firstname,studentID,studentgrades, rows);
	inData.close();

return 0;
}
//****************************************************************************************
//****************************************************************************************
void HEADING ()
{
cout<<"-Student Name   ID    SUB1  SUB2  SUB3  SUB4  SUB5  SUB6  SUB7  SUB8 AVERAGE-"<<endl;
	cout<<"----------------------------------------------------------------------------";
	cout<<endl<<endl;
}
void Sort(string lastname[],string firstname …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

the sort algorithm is wrong. You have to swap all elements of grades array at the same time that the string in word is swapped. You can delete aName2 array.

if (word[k] < aName)
{
    // first swap the string in the word array
    aName = word[k];
    word[k] = word[i];
    word[i] = aName;
    // now swap the elements of the float array
    for(int j = 0; j < 8; j++)
    {
         float temp = grades[k][j];
         grades[k][j] = grades[i][j];
         grades[i][j] = temp;
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

typecast it ofs.write((char*)array,512);

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

what errors? Post a couple of them.

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

>>cin>>*per;
As mention before, per is a pointer that just points to some random memory location. and *per only references the first byte, not the entire string. Unless the purpose of this assignment is to learn character arrays and pointers, then you would be better off using std::string.

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

I originally tried the stringstream thing similar to what you posted but it wouldn't work for me -- just proeuced some gigantic number. After a little more testing I find that the problem was becuse of my use of hex[].

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

HA! I just realized I spelled please wrong in the title! That's embarrassing. Lol!!

Ok -- now I'm going to have to ban you for misspelling that word :) Unless you have a Ph.D. in English, don't worry about the small stuff.

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

You're using Ultima -- so maybe that's why it works on my Vista Home but not on your Vista Ultima. If that's the case, then I can't help you.

Are you running as an Administrator?