0

i am trying to read a char txt file and store the values in 2d array but my console window in not showing any output

enter code here#include <stdio.h>                           
#include<stdlib.h>
#include<iostream>
using namespace std;

int main(){
char A[10][10];
FILE *fp;
int i,j;
fp=fopen("DATA.txt","r");
if(fp == NULL)
 exit(1);

for(int i=0; i<10 ;i++){
for(int j=0; j<10; j++){
    cout<<A[i][j];
}
cout<<"\n";
}    
return 0;

}
john doe
  • 35
  • 1
  • 1
  • 8
  • 1
    You never read anything. – eesiraed Jul 20 '18 at 16:47
  • 1
    First of all please learn how to use C++ stream for files as well, like e.g. [`std::ifstream`](http://en.cppreference.com/w/cpp/io/basic_ifstream). Then you can simply read the file basically the same way you print it. – Some programmer dude Jul 20 '18 at 16:48
  • 2
    And perhaps you should get [a few good books](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list/388282#388282) to read? – Some programmer dude Jul 20 '18 at 16:49
  • 1
    Your array must have been zeroed by chance this is why you don’t see any output – Killzone Kid Jul 20 '18 at 16:49
  • @Someprogrammerdude i am new that is why i need help . – john doe Jul 20 '18 at 16:51
  • 1
    Unfortunately for you, this is not a tutorial site. We can help you with concrete and specific problems, but we don't hold your hand and write all the code for you. Please [the help pages](http://stackoverflow.com/help), especially ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). Also [take the tour](http://stackoverflow.com/tour) and [read about how to ask good questions](http://stackoverflow.com/help/how-to-ask). – Some programmer dude Jul 20 '18 at 16:53
  • I also recommend [this question checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). – Some programmer dude Jul 20 '18 at 16:54
  • @Someprogrammerdude sorry but I am not asking you to write the whole code for me. i i am just asking you the problem with he code that i have written . if you don't want to help its ok dude – john doe Jul 20 '18 at 16:57

0 Answers0