User Profile

Collapse

Profile Sidebar

Collapse
jthep
jthep
Last Activity: May 11 '08, 03:58 AM
Joined: Oct 6 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • jthep
    replied to Reading files
    in C
    so I should try something like:

    Code:
    bool exit = false;
    
    while (!exit)
    {
        inStream.getline(name, 25, '\n');
        if(inStream.eof())
        {
            exit = true;
            break;
        }
        inStream.getline(address, 80, '@');
        if(inStream.eof())
        {
            exit = true;
            break;
        }
        inStream >> yearofbook;
    ...
    See more | Go to post

    Leave a comment:


  • jthep
    replied to destructors
    in C
    I'm not sure but I think one reason to call the destructor is when you have members of the object specifically a pointer that points to objects stored somewhere other than the stack which immediately gets taken care of when you leave the function.

    Say you declare a linked list which has a member head that is a pointer to the first node. The node is stored on the heap, if you call delete it will delete the pointer, but it'll leave...
    See more | Go to post

    Leave a comment:


  • declare a pointer and point it to a struct:

    struct foo *f1;
    struct foo f2;

    f1 = &f2;
    to access:
    f1 -> b = 2.5;
    f1 -> z[0] = 'f';

    I'm guessing foo_init and prt_prt are global variables so accessing them would be the same as above:

    prt_prt -> b to access the first member
    prt_prt -> z to acces the array

    or to put it another...
    See more | Go to post

    Leave a comment:


  • jthep
    started a topic Reading files
    in C

    Reading files

    Hi all,

    I made the following loop to read data from a text file:

    Code:
    inStream.getline(name, 25, '\n');
            while(!inStream.eof())
            {
    			inStream.getline(address, 80, '@');
    			inStream >> yearofbirth;
    			//discard newline
    			inStream.get();
    			inStream.getline(telno, 15, '\n');
    			//discard newline
    			instream.get();
                addRecord(name,
    ...
    See more | Go to post

  • jthep
    started a topic Buffer trouble
    in C

    Buffer trouble

    Hi,

    I'm trying to get user input for a record book but I'm having trouble as I think I'm not making the getline function read the buffer correctly. I have the following variables declared in main:

    Code:
    char name[25], address[80], telno[15], input[10];
    	int yearofbirth, choice, records;
    	yearofbirth = 0;
    	choice = -1;
    Then here's part of the code where it goes wrong:

    Code:
    case
    ...
    See more | Go to post

  • jthep
    replied to Access Violation Error
    in C
    Thanks. The variable start is a private member of class llist that is defined in a header file. Unfortunately I cannot change the definition of the class. As for the copy constructor, you are right, I was actually making a copy. However, even as I consolidate the display() function with int main(), the problem still persist. I was able to figure out the problem was actually coming from my addRecord function.

    Regards,
    ...
    See more | Go to post

    Leave a comment:


  • jthep
    started a topic Access Violation Error
    in C

    Access Violation Error

    I'm trying to get this piece of code I converted from C to work in C++ but I'm getting an access violation error. Problem occurs at line 61. Someone can help me with this?

    The function display(llist mylist) displays a list of choices for a record book:

    Code:
    void display(llist mylist)
    {
    	char name[25], address[80], telno[15], input[100];
    	int yearofbirth, choice, records;
    	yearofbirth
    ...
    See more | Go to post

  • Thanks. Btw, when compiling and running this code on UNIX, is there a way to run javax.swing.JOp tionPane on UNIX? I had some old java projects that I did on eclipse using JOptionPane, I could compile and run in eclipse but I can only compile in UNIX. I couldn't run it without it giving me the UnsatisfiedLink edError.

    Regards,
    Jthep
    See more | Go to post

    Leave a comment:


  • jthep
    replied to Accessing private functions
    in C
    Yes, we're not allowed to change the class definition without consulting. That's why I called the private function read and write in the constructor, destructor respectively.
    See more | Go to post

    Leave a comment:


  • Thanks Jos! Okay....so something like the void initializer(); method in C++ would call the constructor and same thing with the destructor.

    Code:
    void initializer()
    {
        llist();
    }
    and

    Code:
    void initializer(char [] filename)
    {
        llist(filename);
    }
    Then call the function in java by public native void initializer(); Since the constructor is public, I can...
    See more | Go to post

    Leave a comment:


  • So what if I wanted to call the constructor llist() to create a list and initialize all members of the class definition? public native Ilist(); gives me a syntax error since I have no return type. Since both are declared as private, I wrote the constructor and destructor so that it calls the readfile() and writefile() respectively. I'm not directly calling those two functions in the java file, do I still need a native line in there?
    ...
    See more | Go to post

    Leave a comment:


  • jthep
    started a topic Using JNI to access C++ class member functions
    in Java

    Using JNI to access C++ class member functions

    Hi I'm trying to write a JNI for a linkedlist class I wrote in C++. Basically I have a header file with the class definition and a C++ file with the definition of the class member functions.

    I have a record file llist.h

    Code:
    class llist
    {
        private:
            record        *start;
            char          filename[16];
            int           readfile();
            int           writefile();
    ...
    See more | Go to post

  • jthep
    started a topic Accessing private functions
    in C

    Accessing private functions

    I have been given the class definition below:

    Code:
    class llist
    {
    private:
        record *start;
        char filename[16];
        int readfile();
        int writefile();
        record * reverse(record *);
        void cleanup();
    
    public:
        llist( );
        llist(char []);
        ~llist( );
        int addRecord(char[], char[], int, char[]);
        int printRecord(char
    ...
    See more | Go to post

  • jthep
    replied to Stored Proceedure
    OOHHHH that's why. I think my problem is due to the naming convention. I have attributes in one table that has the either the same name or something that's very close to another table that I end up getting all confused or mix and match them up sometimes. =D

    Thanks Jim!
    See more | Go to post

    Leave a comment:


  • jthep
    started a topic Recursion Problem
    in C

    Recursion Problem

    Okay, I have a problem that goes something like this: I have a union of road stripe painters where each painter will only paint a section of 2 miles on the road and charge $200 for the service. If the road is longer than 2 miles, the painter will divide it into three equal parts, charge $100, and subcontract each road to three different painters. Each of the hire will do the same thing where if the road is longer than 2 miles, each of the painters...
    See more | Go to post

  • jthep
    replied to setprecision
    in C
    Okay, there we go, solved it. I used setprecision vs just cout.precision. Don't know why I used that. I noticed I spelt one of my function calls incorrectly. Wonder why there wasn't an error when compiling.

    Regards,
    Jthep
    See more | Go to post

    Leave a comment:


  • jthep
    started a topic setprecision
    in C

    setprecision

    Hi, I'm converting codes that I worked with in C to C++ and having a problem with setprecision. At first the code worked, then I made some changes. When the changes didn't work I wrote it back to how it was before and now it's not working. I keep getting the error message where setprecision is undefined. Can anyone help plz.


    Code:
    #include <iostream>
    using namespace std;
    
    float convertFtoC(int temperature);
    ...
    See more | Go to post

  • jthep
    replied to Stored Proceedure
    Personal_Addres s is a view. Employee_Id field in the view is a person that can either be a full time or part time employee. There are tables for each type of employee.

    Code:
    CREATE VIEW Personnel_Addresses ([Employee ID], [Employee Name], [Address Type],
    	[Street Address], [City], [State], [Zip Code]) AS
    SELECT 
    	P.Person_Id, case when Middle_Name_Initial is null then
    	(Last_Name + ', ' + First_Name) else
    ...
    See more | Go to post

    Leave a comment:


  • jthep
    replied to Stored Proceedure
    Sorry, erase the first question and inserting a new one =D. I have a stored procedure below that displays data from both views and tables.

    Code:
    CREATE PROCEDURE personAddress
    	@Person_Id int = NULL,
    	@Address_Type varchar(35) = NULL
    AS
    	DECLARE @Employee_Id_Count as int
    	DECLARE @Address_Type_Count as int
    
    	SELECT @Employee_Id_Count = count(*)
    	FROM PERSON P
    	WHERE P.Person_Id
    ...
    See more | Go to post

    Leave a comment:


  • Thanks, I figured I couldnt do it using bulk insert unless I created a temp. However, I'm now allowed to create the table with attributes of the same order as the data in the text file as many of my classmates were asking the professor about it. =D
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...