Click here to Skip to main content
14,602,454 members

Managed C++/CLI

 
GeneralRe: c++ program Pin
Member 148568768-Jun-20 9:09
MemberMember 148568768-Jun-20 9:09 
Task:
Write a program in C++ that reads data from a file (ask user to enter file name). The number of elements in file are unknown so, you are supposed to regrow the array and dynamically allocate the memory every time it is needed.
Your task is to implement a function which separates 1-digit and 2-digit numbers from data and store them in two separate files.

Make sure to make independent function for different functionalities.

SAMPLE OUTPUT:

Example
Data.txt: 14 2 3 15 1 82 8 9 10 21 55 12 14 16 18
Data: 2 3 15 1 82 8 9 10 21 55 12 14 16 18
One-digit: 2 3 1 8 9
Two-digit: 15 82 10 21 55 12 14 16 18

solution:

include<iostream>

include<fstream>

include<stdio.h>


using namespace std;
int main()
{
ifstream in;
ofstream myfile;
myfile.open("Data.txt");
myfile<<"2 3 15 1 82 8 9 10 21 55 12 14 16 18 .\n";
myfile.close();

int i,n;
int * p;
cout << "number of total elements ";
cin >> i;
p= new int[i];
if (p == 0)
cout << "Error: memory could not be allocated";
else
{
for (n=0; n<i; n++)
="" {
="" cout="" &lt;<myfile.in&lt;&lt;"\n";

<pre="">
}
cout << "Data: ";
for (n=0; n<i; n++)
cout << myfile.in<< ", ";
delete[] p;


}
return 0;

}

My problem = i am not getting the hint of codition reqiure in this program to separate one digit and 2 digit number.please just give me a hint i will do it.
GeneralRe: c++ program Pin
Richard MacCutchan10-Jun-20 5:19
mveRichard MacCutchan10-Jun-20 5:19 
GeneralRe: c++ program Pin
Eddy Vluggen10-Jun-20 4:11
professionalEddy Vluggen10-Jun-20 4:11 
AnswerRe: c++ program Pin
Patrice T31-Jul-20 12:57
mvePatrice T31-Jul-20 12:57 
QuestionStrings in C | The program gives wrong output on string composed of both Upper case and lower case (Logic : ASCII Comparision) Why? Pin
Member 148492461-Jun-20 2:37
MemberMember 148492461-Jun-20 2:37 
AnswerRe: Strings in C | The program gives wrong output on string composed of both Upper case and lower case (Logic : ASCII Comparision) Why? Pin
Richard MacCutchan1-Jun-20 3:15
mveRichard MacCutchan1-Jun-20 3:15 
GeneralRe: Strings in C | The program gives wrong output on string composed of both Upper case and lower case (Logic : ASCII Comparision) Why? Pin
k50541-Jun-20 4:22
mvek50541-Jun-20 4:22 
GeneralRe: Strings in C | The program gives wrong output on string composed of both Upper case and lower case (Logic : ASCII Comparision) Why? Pin
Richard MacCutchan1-Jun-20 5:05
mveRichard MacCutchan1-Jun-20 5:05 
GeneralRe: Strings in C | The program gives wrong output on string composed of both Upper case and lower case (Logic : ASCII Comparision) Why? Pin
Member 79891221-Jun-20 7:25
MemberMember 79891221-Jun-20 7:25 
GeneralRe: Strings in C | The program gives wrong output on string composed of both Upper case and lower case (Logic : ASCII Comparision) Why? Pin
Richard MacCutchan1-Jun-20 9:28
mveRichard MacCutchan1-Jun-20 9:28 
QuestionRun executable with arguments Pin
Erich Ruth3-May-20 3:04
MemberErich Ruth3-May-20 3:04 
AnswerRe: Run executable with arguments Pin
Richard MacCutchan3-May-20 3:14
mveRichard MacCutchan3-May-20 3:14 
AnswerRe: Run executable with arguments Pin
Victor Nijegorodov3-May-20 4:50
MemberVictor Nijegorodov3-May-20 4:50 
QuestionVisual C++/CLI Pin
F_Square3-Apr-20 15:26
MemberF_Square3-Apr-20 15:26 
AnswerRe: Visual C++/CLI Pin
Richard MacCutchan3-Apr-20 22:00
mveRichard MacCutchan3-Apr-20 22:00 
GeneralRe: Visual C++/CLI Pin
F_Square7-Apr-20 18:05
MemberF_Square7-Apr-20 18:05 
GeneralRe: Visual C++/CLI Pin
Richard MacCutchan7-Apr-20 21:30
mveRichard MacCutchan7-Apr-20 21:30 
QuestionDebugging ... not able to hit breakpoint. Pin
Member 1326109430-Mar-20 2:20
MemberMember 1326109430-Mar-20 2:20 
AnswerRe: Debugging ... not able to hit breakpoint. Pin
Richard MacCutchan30-Mar-20 2:34
mveRichard MacCutchan30-Mar-20 2:34 
AnswerRe: Debugging ... not able to hit breakpoint. Pin
Stefan_Lang30-Mar-20 6:17
mveStefan_Lang30-Mar-20 6:17 
QuestionGetWindowRect wrong dimensions Pin
lacir29-Mar-20 6:57
Memberlacir29-Mar-20 6:57 
AnswerRe: GetWindowRect wrong dimensions Pin
Richard MacCutchan29-Mar-20 7:23
mveRichard MacCutchan29-Mar-20 7:23 
GeneralRe: GetWindowRect wrong dimensions Pin
lacir29-Mar-20 7:28
Memberlacir29-Mar-20 7:28 
GeneralRe: GetWindowRect wrong dimensions Pin
Richard MacCutchan29-Mar-20 20:48
mveRichard MacCutchan29-Mar-20 20:48 
GeneralRe: GetWindowRect wrong dimensions Pin
Victor Nijegorodov29-Mar-20 23:50
MemberVictor Nijegorodov29-Mar-20 23:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.