Hey everyone, I was attempting to get the lastmodified file from a folder, and to do so I used File.listFiles() method which is returning a null pointer exception even though the folder is not empty. I had this piece of code working about two days ago and I am not sure what changed since. I have looking java docs and I have realized that File.listFiles() will return a null if the arbitrary path is not found. But in this case the path does exists and as I mentioned it did work two days ago. The for loop (has comment besides …

Member Avatar
Member Avatar
+0 forum 3

Hi guys, I am confused on how can I access a same class reference object , that is created in class ReadInoiceFile, and be accessed in ReadErrorFile. To be more specific: I have a class called Transaction And then I have a class called ReadInvoiceFile. And finally I have a class called ReadErrorFile. So if I create a reference object of Transaction in ReadInvoiceFile and use the mutator method setOrderNumber to set a value of a variable called OrderNumber, how can I get access to that value in class ReadErrorFile. Because if I create a reference object of Transacton in …

Member Avatar
Member Avatar
+0 forum 3

Hi guys, I am facing some issues trying to deploy my application developed in c# in visual studio. I created a setup/.exe using InstallShield for visual studio 2012 with all the required files for the project included. The target machine where I want to deploy this application is running windows 7 embedded and I just installed .net framework 4.5 on the machine (required for the application). But when I click on .exe on the target machine, the system gets busy for few seconds but then nothing comes up. The application is created in c# using windows form, so a form …

Member Avatar
Member Avatar
+0 forum 3

Hi guys, I am facing some issues trying to deploy my application developed in c# in visual studio. I created a setup/.exe using InstallShield for visual studio 2012 with all the required files for the project included. The target machine where I want to deploy this application is running windows 7 embedded and I just installed .net framework 4.5 on the machine (required for the application). But when I click on .exe on the target machine, the system gets busy for few seconds but then nothing comes up. The application is created in c# using windows form, so a form …

Member Avatar
Member Avatar
+0 forum 1

Hello everyone, I am sort of new in C programming and since I programmed mostly in C++, I may have some mix up on my program which is giving me some errors. I have written a small code , in modular fashion i.e. I have split the .h, definition.c , and main.c files. The program currently has only one function and all that does is read from a text file. My problem is when I compile each file separately I get the error: 'Undefined reference to ReadFromfFile()" (Note: ReadFromFile is a function defined in definition.c and I get this error …

Member Avatar
Member Avatar
+0 forum 8

Hello everyone, This is my first program in C and I have ran into weird issue. I am implementing a simple server & client program in C. From my main() in client I call a send_message() function which I believe binds with server and sends the message to the server side. The function proto type for send_message is: `int send_message(int Port_num, char*input)` where Port_num is for port number to connect to and input: is a user input. For a test I tried printing the user input as such `send_message(3100,"HELLO")`. This prints Hello in the send_message function BUT, if I instead …

Member Avatar
Member Avatar
+0 forum 1

Hi, I am reading from a text file and stored it onto a string variable. Now I want to split the string and I tried looking it up on the web and found the strtok () function but that only works on a char type. Here is my code snippet: [code] #include <iostream> #include "Stack.h" #include <string.h> #include <fstream> using namespace std; int main() { Stack list; ifstream ReadFrom; string line; (getline(ReadFrom, line));[color=#FF6666] split = strtok(line.c_str(),",.( )") // this does not work.[/color]; [/code] Can some one give me an idea on how to accomplish this. Note: variable line has to …

Member Avatar
Member Avatar
+0 forum 1

I am trying to do some arithmetic operation on a stack but I am little confused on how would I implement it. For instance I have a statement: add(multiply(2,3),4) which is equal to 2x3 = 6 + 4 = 10. If I place this on the stack, it would look something like this: ) 4 ) 3 2 ( multiply ( add My question how would I implement the above function here. In other words what should I do to make the program interpret the paranthesis in the right way, i.e. if you pop out 4, then 3, and then …

Member Avatar
+0 forum 0

Hi guys, Please can someone explain me how would I split a string into groups. In other words, I have a string of numbers, as such: 123456789 I am supposed to store them in linked list nodes as such: node 1: 1 node 2: 2345 node 3: 6789 I was thinking to do something like get the length of the string. In this case: 9 Divide by 2 and store in variable div ( in this case div = 4) Then mod length/2 and store in var mod( in this case mod = 1) Then I am stuck thinking how …

Member Avatar
Member Avatar
+0 forum 1

D.I.C Head ** Joined: 22 Oct, 2007 Posts: 51 [IN] My Contributions I am little confused here. So please help me. I am given a txt file in the following format 110001 + 123500 ...... I need to read these numbers into the source file, do the addition and then print the result. My approach was to use a for loop to read a character at a time until an operator such as '+' is found. Store that number into a var1, then continue reading after the operator symbol '+' until new line is approached. Store that number into var2. …

Member Avatar
Member Avatar
+0 forum 3

I am trying to write a program in which a big text file is read and then user searches for a word and replaces it with another word. To implement this I was thinking to store the file read into an array since that would the easiest way to implement it (as far as I Know) and then compare each element with the word to be searched and when found replace it. Here is my code: [code] #include<iostream> #include<fstream> #include<string> using namespace std; int main() { ifstream insert; ofstream output; string lineread; insert.open("test.txt"); if(insert.fail()) { cout<<"File failed to open"<<endl; } …

Member Avatar
Member Avatar
+0 forum 7

Hi, I am trying to write an address book. The problem is: in my class declaration I declared a mutator. In the implementation, I am asking the user to enter his address, city, state and zip. So my prototype void set_add(string, string, string, int). In other words I am trying to set the address, city, state, and zip variables to the one entered by the user. To implement this I am using reference. But no matter what I put in as arguments while calling from main, I keep getting the error: variable 'variable' not declared. Here is my code for …

Member Avatar
Member Avatar
+0 forum 4

Hi, I declared and implemented a print() function in a class. But when I call this function it is giving me an error: which says that function does not take 0 arguments. But what should my arguments be. I have posted the part of the code for more specification. Thanks. [code] /************class header******************************/ class addressType { private: string St_address; string city, state; int Zip; public: void print_add(string, string, string, int); void get_add(); void set_add(string, string, string, int); addressType(); ~addressType(); }; #endif /*****************implementation of print & set function*****/ void addressType::set_add(string street, string cit, string st, int zip) { St_address = street; …

Member Avatar
Member Avatar
+0 forum 5

I am writing a program in which a print function takes in users' street address(string), city (string) , state (string), zip(int). What will my return be for this function? My code snippet is this: [code] string addressType::print_add(string str, string Cit, string St, int Z) { cout<<str<<endl; cout<< Cit <<","<<St<<endl; cout<<"Zip: "<<Z<<endl; return ;//what should I return here? } [/code] Thanks.

Member Avatar
Member Avatar
+0 forum 1

Hi I am writing a address book program that is giving a run time error. Please if someone can compile and check this error, and then explain/ show me how can I resolve it. I am pasting my code in parts here as well as attaching the files. Also please someone explain me, how can I print the user input address in the main(). I mean what should my argument be for the print_add() when I call it in main(). I really appreciate your help. Thanks. [code] /**********Header file*****************/ #ifndef addressType_H #include<iostream> #include<iomanip> #include<string> using namespace std; class addressType { …

Member Avatar
Member Avatar
+0 forum 1

Please can someone show me how would I create a file using fstream that would take the contents from another existing file and user input sentence. for example: I have file1 with some contents The user inputs a sentence Now I want to create a file using streams that has contents of file1 and sentence. My possible coding [code] ofstream output; output.open("file2.txt"); output<<file1 + sentence<<endl; output.close(); [/code] To me something in the code does not seem right.

Member Avatar
Member Avatar
+0 forum 4

I have an assignment to implement a salesperson class. Here is the layout I got from prof. My questions are typed in red between function prototypes. Any help is appreciated. Thanks. [code] cClass Salesperson { public: Salesperson(); //default constructor [COLOR="Red"]// I know that a default constructor is suppose to set the values by default but how would I do this implementation for this constructor. I mean what would this constructor set the value for and how. [/color] ~Salesperson(); // destructor Salesperson(double q1, q2, q3, q4); void getsales(); [COLOR="Red"][COLOR="Red"]// how would I use this function [/color] void setsales(int quarter, double sales); …

Member Avatar
Member Avatar
+0 forum 3

I am trying to read a file from fstream in a switch statement but something in the code seems to be stopping this part of my code to be read by the compiler. Please some one let me know what am I doing wrong. Its not the text file thats having problem, for sure. [code] #include "stdafx.h" #include <iostream> #include<fstream> #include<iomanip> #include<stdlib.h> using namespace std; int main() { char option = '\0', user; cout<< setiosflags(ios::left)<< "\t \t \t UH Visitors Parking "<<endl; cout<< setiosflags(ios::left)<< "_______________________________________________________________"<<endl; cout<<"\n"<<setiosflags(ios::right)<< "\t Help \t Car \t MotorCycle \t SeniorCitizen \t Quit"; cout<<"\n"<<setiosflags(ios::left)<<"_______________________________________________________________"<<endl; cout<<"Please select an …

Member Avatar
Member Avatar
+0 forum 10

Hi everyone, I have worked some more on my code and this time I am getting some error that I am not able to resolve. Please help me. The error says: "initialization skipped by case label." Please show me how to resolve this. Here is the code. The error has a remark in red. [code] // Hw6_Bhasin.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include<fstream> #include<iomanip> #include<stdlib.h> using namespace std; int CarParking(int); int main() { int minutes = 0; char option = '\0', user; ifstream input; ofstream output; cout<< setiosflags(ios::left)<< "\t \t \t …

Member Avatar
Member Avatar
+0 forum 5

Hi, I was working on my assignment and on compiling everything works perfect except at one place the compiler seems to skip the cin command. Here is my code: the skipped command is highlited in red. This particular part is suppose to delete the every occurence of an integer entered by the user. [code] #include "stdafx.h" #include<iostream> #include<string>; using namespace std; typedef int* ArrayPtr;//creates a pointer for dynamic arrays. void Erase(int [], int* ,int* ); int main() { char choice; int itemCount= 0, SearchElement=0; //itemCount keeps track of the size, SearchElement is for the element needs to be deleted. cout<<"You …

Member Avatar
Member Avatar
+0 forum 6

Hi guys, being a beginner I have some trouble with pointers. I don't know but something about using pointers is just not getting clear to me. My assignment requires that from an array of given values, the user inputs a particular integer whose every occurrence with in the array should be deleted and the size of the array should then be reduced respectively. I tried but I am not getting how can I accomplish this with a pointer. Here is the my code: [code] // HW5_Bhasin.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> using …

Member Avatar
Member Avatar
+0 forum 4

Hi guys, this 2D arrays is not making sense to me. Some how I am just too confused. What am trying to do is average the rows in 2D array and average the columns in the 2D array seperately. Here is the code snippet that I have trouble implementing. The array is declared as Data[5][4]. [code] double Mean(const int Data[][4], int r[][4], int c[][4]) { int Avg[5][4]; int sum=0, i; for(int r=0; r<5; r++) for(int c=0; c<4;c++) Avg[r][c]= r[r][c]+c[r][c]; return sum; } [/code] Any help is appreciated. Thanks.

Member Avatar
Member Avatar
+0 forum 3

Hi, I was doing my assignment which states: The user to enter a string which should be stored in Input_String[]. 2) Then reverse the string and save it to another array called Output_String[]. [COLOR="Red"][/COLOR] I am having trouble with the second part where I need to save the string to another array. I am not sure how would I do. Here is what I have done: [COLOR="Red"][/COLOR] [CODE] // Hw-4_Bhasin.cpp : Defines the entry point for the console application. //void rev_str(); #include "stdafx.h" #include<iostream> #include<string> #include<cmath> using namespace std; int main() { char option; void rev_str(); double Mean(const int Data[5][4], …

Member Avatar
Member Avatar
+0 forum 4

HI I was writing a program that passes a string into an array, reverses the string, and passes to another array. Half way done with my function definition I compiled and got some errors, that I am not able to understand. Here is my code: [code] // Hw-4_Bhasin.cpp : Defines the entry point for the console application. void rev_str(void); double Mean(const int Data[5][4], int, int); void frequency(const int Data[5][4], int, int); #include "stdafx.h" #include<iostream> #include<string> #include<cmath> using namespace std; int main() { char option; cout<<"\n Please choose from the given menu."; cout<<"\n R{Reverse String] M[Matrix] Q[Quit]."<<endl; cin>> option; switch(option) { …

Member Avatar
Member Avatar
+0 forum 6

Hi everyone, I was writing a program and out of the 4 functions, one void function is giving 4 errors that I am not able to understand. The function is : void Conversion(double, double, char). I am posting my program, including the function that is giving the errors. I have highlighted the function in red. Any help is appreciated. [CODE] #include "stdafx.h" #include<iostream> #include<cmath> #include<iomanip> using namespace std; int main() { char option, unit; double minTemp, maxTemp; void Pattern(void); double SineWave(void); void Convert(double,double,char); void Quit(void); cout<<"Please select an option from the following menu."<<endl; cout<<" P[Pattern] S[Sinusoidal] C[Conversion] Q[Quit] "<<endl; cin>>option; …

Member Avatar
Member Avatar
+0 forum 9

The End.