HA - HWzone Forums
Skip to content
  • Create an account

ח א

registered user
  • Number of messages

  • joining

  • Recently visited

Recent Visitors

Visitors to your profile are disabled, and you can not see who recently visited your profile.

The ratings of H.A.

Zone Newbie

Newbie Zone (1/6)



  1. Ok the program did not recognize the file location, I moved to another folder and ran fine.
  2. A. Thanks b. In the middle I did not use len c. The file is in the folder and its contents: Mendi Wolf Itz Chaim Nachman Choen Hana Rivka Golan I did not know where to insert, for safety I put in each folder
  3. I created an array of structures that reads data from a running file, an error appears. The data was not read from the file. Here is the code. Many thanks to the helpers !!! #pragma warning (suppress: 4996) #define _CRT_SECURE_NO_WARNINGS #include using namespace std; #include #include int len ​​(struct PERSON p) {int leng = strlen (p.first); leng + = strlen (p.last); leng + = 4; return leng; } void fullName (char * p, struct PERSON & person) {char fullName [52]; strcpy (person.first, fullName); strcat (fullName, ""); strncat (fullName, person.middle, 1); strcat (fullName, ""); strcat (fullName, person.last); p = fullName; } struct PERSON {char first [25]; char middle [25]; char last [25]; char * fullN; }; int main () {struct PERSON * people; int num; cout << "enter num of persons" < > num; while (num <0) {cout << "ERROR / n enter new num" << endl; cin >> num; } people = new PERSON [num]; ifstream inData; inData.open ("data.txt"); if (! inData.is_open ()) {cerr << "Cannot open input file \ n"; exit (EXIT_FAILURE); } int i = 0; while (! inData.eof ()) {char str [100]; inData >> people [i] .first; inData >> people [i] .middle; inData >> people [i] .last; people [i] .fullN = new char [len (people [i])]; fullName (people [i] .fullN, people [i]); i ++; } inData.close (); return 0; }
  • Create new ...

At the top of the news:

new on the site