Duki 552 Nearly a Posting Virtuoso

Hey Everyone,

I've applied for grad school this coming Fall and would like to get your opinions on it. I'm currently working full-time at a software engineering company, and will be taking one to two classes per semester. Has anyone gone through a similar experience while working in the field? Was it difficult? Was it worth it?

Duki 552 Nearly a Posting Virtuoso

I'm surprised Narue hasn't showed up to tell me how I should never consider using typedef void *.

NARUE: I didn't write the code. I just want it to work while we wait for approval to re-write the component.

Duki 552 Nearly a Posting Virtuoso

Sounds cool - good luck with that!

Duki 552 Nearly a Posting Virtuoso

You can't do pst = conn though:

gensock.cpp(763) : error C2440: '=' : cannot convert from 'connection *' to 'socktag *'

Duki 552 Nearly a Posting Virtuoso

You're right in most of your assumptions. Though, I need the memory address of 'new connection' - the address that conn points to.

Later, in gensock_getchar, we then create a new pointer, conn, and point it to the value of *pst as it's memory location.

I hope that makes sense?

Duki 552 Nearly a Posting Virtuoso

The only modification I've made is the *pst = conn; - it was miswritten as *pst = retval, which is not at all what needs to be done.

You are correct - a 0 return signifies a successful connection. The typedef was originally typedef void FAR * socktag.

I want *pst to be the memory address of conn. Because later down the road, we do this:

int gensock_getchar (int st, int wait, char * ch)
{
   int retval = 0;
   connection *conn;

   conn = (connection *)st;   //<- st = pst

   if ((retval = conn->cc_getchar(wait, ch)))
      return (retval);
   else
      return (0);
}

Remember: I didn't author this.

Duki 552 Nearly a Posting Virtuoso

I don't think so. I've stepped through each line - I'm pretty positive it's hitting.

Duki 552 Nearly a Posting Virtuoso

Yeah, this code is ancient. Not written by me, I promise. I'm just a debugger. :)

It's a tweaked version of BLAT for AIX systems. We're (I think) putting in an enhancement request to rewrite the whole component, but for now I just need to get it working.

I'm having an issue getting *pst to contain the memory address of conn.

Duki 552 Nearly a Posting Virtuoso

Hey everyone,

I'm trying to do something like this:

typedef void * socktag

int gensock_connect (char * hostname,
                     char * service,
                     socktag * pst)
{

   int retval;

   connection * conn = new connection;

   if ((retval = conn->get_connected (hostname, service)))
   {
      gensock_close(0);
      *pst = 0;
      return (0);
   }
   *pst = conn;

   return (retval);
}

So when it gets to the line *pst = conn;, *pst never gets assigned the value of conn's memory address. It stays at 0. But I have confirmed it does actually hit the line, and the address of conn is 0x...119de7610. Am I missing something?

Duki 552 Nearly a Posting Virtuoso

What have you tried so far?

Duki 552 Nearly a Posting Virtuoso

I think this site will help you a lot. Don't give up!

Duki 552 Nearly a Posting Virtuoso
Duki 552 Nearly a Posting Virtuoso

Anyone with dbx experience know how I can watch a variable?

Duki 552 Nearly a Posting Virtuoso

Ok, makes more sense now. I guess that's where I was getting confused. Now that I know they're actually passing in char* and not just char, I think my question isn't relevant anymore. Thanks guys.

Duki 552 Nearly a Posting Virtuoso

Ok, I see now. They're using LPSTR, something I've never heard of. I'm thinking this whole component needs updating.

Duki 552 Nearly a Posting Virtuoso

What happens if I have a method declaration of:

int method( char * a, char * b, int * c );

and then I pass in:

char a;
char b;
int c;
method(a, b, &c);

This has me a little puzzled. What values will be passed by reference?

Duki 552 Nearly a Posting Virtuoso

No, no. Prices are relative to your knowledge on the subject, right? No need to lower your prices.

Duki 552 Nearly a Posting Virtuoso

What problems are you experiencing now?

mikulucky commented: Snap +1
Duki 552 Nearly a Posting Virtuoso

Have you tried doing this in one file? Maybe that will help you understand what's going on. You can't declare an object in one file (or a method for that matter) and then expect to be able to use/change it somewhere else. Your objects are not globally accessible (unless declared as such).

Have a look at how the call stack works - it's a challenging topic if you're new to programming, but will help you tremendously I think.

Duki 552 Nearly a Posting Virtuoso

I charge $25/hr to check for errors.

Duki 552 Nearly a Posting Virtuoso

Ok, so if on my unix box I see a call to:

#if INCL_WINSOCK_API_PROTOTYPES
WINSOCK_API_LINKAGE
int
WSAAPI
connect(
    IN SOCKET s,
    __in_bcount(namelen) const struct sockaddr FAR * name,
    IN int namelen
    );
#endif /* INCL_WINSOCK_API_PROTOTYPES */

Does that mean something's not right?

Duki 552 Nearly a Posting Virtuoso

Is it possible to somehow use the winsock API on a unix machine?

Duki 552 Nearly a Posting Virtuoso

Ok, I was confused on what FAR was so I wasn't sure.

Duki 552 Nearly a Posting Virtuoso

My questions continue to become more and more complex - sorry. How does this:

int (FAR PASCAL *pgensock_getchar) (socktag st, int wait, char FAR * ch);

compare to this:

int gensock_getchar (int st, int wait, char * ch)
{
   int retval = 0;
   connection *conn;

   conn = (connection *)st;

   if ((retval = conn->cc_getchar(wait, ch)))
      return (retval);
   else
      return (0);
}
Duki 552 Nearly a Posting Virtuoso

Does anyone know what this is? It's in a piece of code I'm trying to debug, and I've never seen it:

typedef void FAR * socktag;

Also, could someone explain the difference between these two lines (after the typedef executes):

socktag SMTPSock;
int SMTPSock;
Duki 552 Nearly a Posting Virtuoso

I guess I should be more descriptive:

When I step through the while() loop, and do 'print ch' and 'print *index', the values never seem to change from '\0'. I don't understand how they became '\0'.

Also, is it possible we should be checking for '\0' instead of '\n'? This code works fine in Windows but is crashing in AIX.

Duki 552 Nearly a Posting Virtuoso

Thanks for replying - while debugging it looks like the value never changes from '\0'. I'm not sure what the point of this method is - it looks like it sets 'ch' to '.' and then ... no clue. What's the point in doing ch='.' and then while(ch != '\n')?

Duki 552 Nearly a Posting Virtuoso

Can someone please provide some insight on this:

int get_smtp_line( void )
{
   char ch = '.';
   char in_data [255];
   char * index;
   int retval = 0;

   index = in_data;

   while (ch != '\n')
   {
      if ( (retval = gensock_getchar (SMTPSock, 0, &ch) ) )
      {
         gensock_error ("gensock_getchar", retval);
         return -1;
      }
      else
      {
         *index = ch;
         index++;
      }
   }


   return atoi(in_data);
}

I'm working on an e-mail issue in AIX, and am getting this:

Segmentation fault in get_smtp_line() at line 254 in file ""

I don't understand what's going on here at all though - was hoping someone here might be able to give an "assumption" of what it might be used for. Thanks in advance.

Duki 552 Nearly a Posting Virtuoso

I'm not positive this is the right place to post this.

We're starting analysis for converting to UTF-8 on our application. During testing, all of our test data is displayed incorrectly in visual studio - our two-bye UTF-8 characters are being displayed as two one-byte ASCII characters. Is there a way to change this?

Duki 552 Nearly a Posting Virtuoso

Thank you - that is all I wanted. :)

Duki 552 Nearly a Posting Virtuoso

>I think they'll understand the kid forgetting his meds and flipping out. It's the internet.

Regardless, it presents an unprofessionalism for the board as a whole - something I wouldn't want to be associated with. If they aren't regulars to DaniWeb, they have no idea of the real reputation.


Thanks for the response everyone. I appreciate the support - hopefully Dani can chime in here sometime.

Duki 552 Nearly a Posting Virtuoso

Would it be possible to have negative reputation left by someone who has been banned or is still under "newbie" status or that may be a personal attack hidden? I sometimes post questions asking for help related to an issue at work - I hand out the threads to fellow employees so they too can track the new messages. There are reputation comments on my profile (one in particular) that I would not exactly want my co-workers to see... regardless of how ludicrous the comment is.

Duki 552 Nearly a Posting Virtuoso

Hey everyone,

We're trying to figure out if it's possible to use winsock on an AIX system? If not, is there any native support in C++ for unix based machines and e-mail support, without importing 3rd party libraries?

Duki 552 Nearly a Posting Virtuoso

Hey everyone,

My computer (nvidia fx480) is experiencing some pixelation. At random times (haven't noticed a pattern) my monitor (HP 2509m) will show green pixels in darker areas on the screen. Usually refreshing the background image or something similar with correct this, but I'd really like to get it fixed. Any ideas? I've tried updating the drivers already.

Duki 552 Nearly a Posting Virtuoso

Hey all,

I'm trying to write a batch file to parse a text file I have. Here's the pseudo code I'm trying to pull off:

Example makefile.txt:

text text text
text text text
text text text text text text
text text text text text text
text text text

T1 = SomeFileToProcess
T2 = AnotherFileToProcess
--------------

all: $(T1) $(T2)

//Given:  current directory has makefile.txt
While !eof
    If "$(T1)" exists in makefile.txt
        echo "T1 = SomeFileToProcess"
    If "$(T2)" exists in makefile.txt
        echo "T2 = AnotherFileToProcess

Is this possible with a batch file? Is there another native XP language that would be easier to write this in?

Thanks for any help.

Duki 552 Nearly a Posting Virtuoso

Hey everyone,

I'm trying to get started with SQLite. My app keeps force closing on this activity:

public class ViewActivity extends Activity {
    
    private TextView company;
    private BillMeDB dh;
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.all);
        
        company = (TextView) findViewById(R.id.Company1);
        BillMeDB db = new BillMeDB(this);
        
        db.open();
        long id;
        
        id = db.insertEntry("Power", "AEP", "item", "2010.9.15", "w2", "2010.9.24", "2011.1.1", 75.77);
        id = db.insertEntry("Cell Phone", "Verizon", "item", "2010.9.15", "w2", "2010.9.24", "2011.1.1", 185.45);
        
        Cursor c = db.getEntry(1);
        if (c.moveToFirst())
            company.setText(c.getString(1));
        
        db.close();  
        
//       Cursor c = BillMeLoad.database.fetchAllEntries();
            company.setText(this.dh.getEntry(0).toString());  

        }
    }

I can't figure out why though. It blows up(I think) when it starts creating a DB. Here's my DB file - I have no idea where I've gone wrong, but apparently something isn't right. Can someone give me a hand?

My DB File:

package com.caleb.billme;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class BillMeDB {

    public static final String KEY_BILLNAME = "billname";
    public static final String KEY_COMPANY = "company";
    public static final String KEY_ROWID = "_id";
    public static final String KEY_ITEM = "item";
    public static final String KEY_DUEDATE = "duedate";
    public static final String KEY_REMFREQ = "remfreq";
    public static final String KEY_REMDATE = "remdate";
    public static final String KEY_ENDDATE = "enddate";
    public static final String KEY_DUEAMNT = "dueamnt";
    
    private static final String TAG = "BillMeDB";
    private DatabaseHelper DBHelper;
    private SQLiteDatabase db;
    
    private static final String DATABASE_CREATE =
        "CREATE TABLE BillTable (_id integer primary key autoincrement, "
        + "billname text not null, company text not null, …
Duki 552 Nearly a Posting Virtuoso

Wow that's terrible!!!! I wish i could help but i don't know what to tell you!!! I hope you're not mad at me?????? Good luck on your project????!!!!!

Duki 552 Nearly a Posting Virtuoso

No no - there's nothing in amt[9] either. Set a break point at the beginning of your "lowest" function and step through the code. You'll easily see why you shouldn't be indexing at anything to do with the variable "length".

Let's assume you have 5 grades and "length" = 10 (which you've passed in). If you compare everything in your amt[] array, you'll eventually hit a zero, which will always be lower.

Another part of your code to look at:

for (int i=0; i< length; i++) 
         {
             if(amt[i] < lowest)
             lowest=amt[i];
             }
             cout<<"\nLowest   :   "<<lowest;
             cout<<"\n\n\n";

You don't need to compare every index, right? Only the indexes that have had grades added. So maybe instead of (i < length), you should do something like (i < num_grades), don't you think?

Duki 552 Nearly a Posting Virtuoso

Perhaps you should take another look at how you're indexing amt[] in your "lowest" function.

Here's a hint: (length - 1) isn't what you want to use. amt[length - 1] is 0, and you're not going to have a grade lower than that, right?

Duki 552 Nearly a Posting Virtuoso

For what it's worth Narue, I've been wishing you would write a book for a while now.

Duki 552 Nearly a Posting Virtuoso

Not to be picky here, and it has very little to do with the question you're actually asking, but don't get in a habit of meaningless variable and function names (e.g., v, n, xVec, asum, etc.). In fact, the opposite is a more industry accepted approach. I made the mistake during my schooling of, in an attempt to get the program working, not worry about what I called my variables because I knew what they meant and that's all that mattered. However, when I started working on larger more independent projects (projects that might actually be picked up by another programmer one day or that has over 500 lines of code) I found myself continuing my old habits without realizing it sometimes.

Now, while you're learning and in school, start doing the opposite - over describe your variables. It's ok for your professor to jot down meaningless variables in class, as they're merely for demonstration. As for your programs, attempt to be as descriptive as possible with both your functions and variable names.

Some examples from the software I debug daily:

FfsApportionmentDocumentAmendmentDataEntryCritic
FfsAssetDetailAcctgLineIdentityPtr

GetRuleCustomerAccountTreatment()
GetItemLineOriginalAmount()
AddDocumentTypeDefinedAccountingLineCodeColumns()

Just some food for thought.

Duki 552 Nearly a Posting Virtuoso

How much have you dealt with recursion and/or trees? Just wondering which answer to help you find based on the level of your coursework.

Also, what are your inputs? Is X constant? Are all variables input by the user? Or are you trying to solve for X here. "Solve the equation" can be very ambiguous in this case...

Duki 552 Nearly a Posting Virtuoso

Sir,

I want to get paid to do your homework. Please send a money order in the amount of $100.00 to:

<<snip>>

Thank you.

Duki 552 Nearly a Posting Virtuoso

Whoa whoa wait... No. :)

You can still add Student objects to your list. You just need to modify your Student class to have the new data you need.

e.g.,

string FirstName;
string LastName;
etc.
etc.

Now, if you are wanting to both declare a new Student and add it to your list, you are correct in your new parameter list.

Duki 552 Nearly a Posting Virtuoso

You're closer than you think with this.

void getStudent (string student)
{ 
     studentnode* current;
     current = start; 
     while(current!=NULL)
     {   
         if(current->data == student)   
         {    
               cout << "The Specified Student Has Been Found: "<< endl;
               cout << student <<endl;  
                 break;  
                 }  
                  current = current->next;  
                  }
                  }

       

       //display all the items in the list
       void print()
       {
            studentnode * current;
            current = start;
            
           //loop through all nodes, each time doing something
           while(current != NULL )
           {
               //display the data of the current node
               cout << current->data << endl;
               
               //move current to next node
               current = current->next;               
           }     
       }
};

What if you modified the parameter to getStudent(int id) - then you could, instead of cout << student << yada, just do current->printData(), right?

Duki 552 Nearly a Posting Virtuoso

Have you dealt any with operator overloading?

I'm not sure exactly what you're asking though - are you wanting to add members of the same class (e.g., Create one large string of "Student - University - ID") or are you wanting to add members from other classes (e.g., string temp = StudentA.name + StudentB.name)?

Duki 552 Nearly a Posting Virtuoso

The solution that comes to mind right off would be inherited classes with overloaded functions (you may not have reached these topics yet in your coursework).

If you have, just do

//pseudo

class Time

overload <<

... class MilTime

overload <<

... class StandTime

overload <<
Duki 552 Nearly a Posting Virtuoso

I'm quite sure Fbody's post will do what you want - he's just not going to do everything for you.

e.g.,

const int COUNT = 5;
Speaker myArray[COUNT] = [0, 1, 2, 3, 4 };

void displayInfo(int requestedItem) {
  if (requestedSize < COUNT)
    cout << myArray[requestedItem - 1].showName();
    etc.
    etc.
  else
    cout << "You have requested an invalid element." << endl;
}

He's merely demonstrating the usage of arrays to access your methods. What you're referring to isn't exactly what you want to do.

for() - Do this for every element
if() - Do this for the selected element

What I would suggest is remove your if()'s and try using switch()

Fbody commented: thx +2
Duki 552 Nearly a Posting Virtuoso

What he meant to say was,

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <conio.h>
#include <cmath>

using namespace std;


int main()
{
	char ans;
	srand(time(0));
	int randomNumber = rand() % 10+1;
	bool guessed = false;

    do
    {
		guessed = false;
		system ("cls");
		cout << "\tThe Number Guessing Game\n\n";
                randomNumber = rand() % 10+1;

		do
		{
			int guess = 0;
			
			cout << "Enter your guess (#1-10): ";
			cin >> guess;

			if (guess < randomNumber)
				cout << "Your guess was too low\n\n";

			if (guess > randomNumber)
				cout << "Your guess was too high\n\n";

			if (guess != randomNumber)
				cout << "Try Again\n";

			if (guess == randomNumber)
			{
				cout << "\nCongratulations! You've guessed the number.\n\n";
				guessed = true;
			}
		}while (!guessed);



	cout <<"You want to try again??";
	cin >> ans;

    } while ((ans=='y')||(ans=='Y'));

    cout <<"Thank You!!";
    getch();

  return 0;
}

You don't want to seed srand() more than once during your program - just a bad habit to get into. You only need to seed it once.

Duki 552 Nearly a Posting Virtuoso

I'm not sure - I don't use Visual C++. I'm sure someone with more experience will hop on soon.