| juancarpinteiro (3) | |||
|
this is my code i don't know why it isn't doing it #include "stdafx.h" #include <iostream> #include <cstring> #include <string> #include <iomanip> #include <stdio.h> #include "windows.h" #include <fstream> using namespace std; void write_file(); void sort (int n); void swap(int *p1, int *p2); void swap2( string *a1, string *a2); int get_int(int default_value); void seeWhatsinthearray(); void get_array(); void seeWhatsinthearray2(); void average(int grades[5]); const int length = 5; int grades[length]; string names[length];
thanks guys | |||
|
Last edited on
|
|||
| Chervil (812) | |||
|
You don't say what problem you have exactly. Here's one line which looks incorrect: name = names[i].c_str();should be : strcpy(name, names[i].c_str());Make sure array name is large enough to hold the result, or use strncpy()http://www.cplusplus.com/reference/cstring/strncpy/ On the other hand, why not just do this and forget about the intermediate array:
| |||
|
Last edited on
|
|||
| juancarpinteiro (3) | |
|
omg i'm so thankful to you ............ also for some reason my code doesn't work with the grades. any pointers ? | |
|
|
|
| juancarpinteiro (3) | |
|
i fixed the code but still this is my output Enter file name: e:\wa this is the information on file: name grade S. Long -858993460 A.Smith -858993460 T. Phillip -858993460 J. White -858993460 J. White -858993460 ╠╠╠╠♦ -858993460 Press any key to continue . . .\ whats wrong with the writing code for the int array? | |
|
|
|