Home Posts Topics Members FAQ
lolcheelol
25 New Member
Expand|Select|Wrap|Line Numbers
- ifstreamin1("txtxtxtx");
- intct=0;
- int*p=newint[1300];
- intforever=1;
- while(forever){
- in1>>*(p+ct);
- if(*(p+ct)==-1)break;
- ct++;
- }//WHILELOOP
- for(inti=0;i<ct;i++){
- cout<<"\t"<<*(p+i);
- if((ct)%15==0)cout<<"\n";
- if((ct)%150==0)cout<<"Entertocontinue";
- }//FORLOOP
- getch();
- cout<<"\n\n\tTotaldata="<<ct;
- deletep;
- in1.close();
So basically I'm trying to get a 15x15 matrix of the numbers from the text file I have and after a 15x15 matrix is printed I want the user to have the option to hit a key to continue. It prints all the numbers correctly, but it doesn't do the matrix in the way I would like it to. Any help is appreciated. Thanks
Feb 12 '10 #1
Subscribe Reply
8 2444
whodgson 542 Contributor
What are you getting and what do you want?
Feb 12 '10 #2
reply
lolcheelol 25 New Member
this is what i'm getting.
6 198 651 694 692 196 594 762 698
321 265 517 559 1010 648 131 621 968 513
544 30 863 827 688 311 758 284 729 845
285 164 896 343 1009 23 371 429 516 316
357 470 1007 789 181 530 56 148 214 726
1016 871 398 766 423 728 657 606 496 249
119 942 410 937 362 592 755 159 251 563
678 938 683 201 877 204 121 120 192 380
40 261 773 645 586 904 482 2 17 63
194 509 221 387 433 579 359 356 510 403
348 526 390 786 86 512 714 82 260 206
302 701 150 888 59 700 329 803 596 788
100 314 219 166 354 113 253 68 436 614
1012 1021 911 612 853 39 640 385 331 894
949 432 522 624 459 984 342 553 187 446
965 663 816 619 126 293 1022 545 748 27
824 564 5 836 442 636 197 608 826 450
381 957 671 70 236 550 146 763 55 310
572 488 93 313 575 1008 801 525 715 774
402 865 905 94 97 552 435 697 1018 13
882 931 494 838 244 118 807 231 941 224
860 295 186 777 397 389 754 338 898 946
468 1014 780 537 932 752 176 528 964 542
660 915 643 555 157 347 438 1020 388 878
950 444 62 337 585 987 315 641 976 422
373 527 178 966 587 969 64 274 607 851
639 303 693 498 476 167 569 106 395 649
995 379 50 369 102 1015 46 628 77 797
300 73 735 901 271 1002 42 577 222 142
740 140 887 676 275 702 890 521 779 713
180 202 200 506 91 561 484 372 885 143
99 237 848 243 234 821 971 103 574 116
15 35 912 308 744 925 908 289 1001 11
280 804 246 535 365 419 229 813 599 168
57 732 160 210 367 138 427 21 708 511
88 7 778 12 363 672 751 980 502 914
239 709 109 223 874 462 749 480 493 903
881 247 4 453 539 294 266 264 696 985
474 979 26 704 917 864 560 111 920 515
681 205 370 1 632 208 523 52 286 74
424 364 95 376 296 24 259 798 426 254
114 318 155 309 16 721 434 795 664 1011
320 125 549 207 658 165 615 742 605 741
98 341 487 669 399 8 642 829 25 616
72 83 986 943 916 217 129 185 880 899
855 844 182 108 475 440 378 602 305 133
737 782 799 654 595 298 769 787 584 923
334 1013 746 805 566 981 49 934 122 404
144 130 33 22 336 791 69 486 582 472
520 988 518 54 854 171 327 252 14 139
48 897 652 924 483 831 810 936 1019 747
921 497 392 682 837 479 292 820 884 112
828 333 907 28 944 618 918 765 951 790
601 361 469 647 213 546 720 919 190 152
665 567 282 514 989 134 411 416 841 428
731 461 75 1017 834 597 227 733 947 452
705 115 85 29 291 464 89 686 250 258
707 653 879 591 818 324 859 255 455 161
993 588 893 346 961 307 785 536 158 580
431 335 650 58 783 623 626 456 929 220
963 147 71 939 730 211 193 945 374 633
781 127 360 832 36 617 394 290 232 830
172 935 933 767 400 952 3 233 967 350
383 909 449 241 892 858 990 970 711 998
508 154 562 465 1023 533 630 784 634 124
802 188 323 598 978 955 495 739 876 718
216 297 84 273 151 557 866 576 646 954
629 611 352 842 991 812 445 344 529 558
80 554 953 287 110 104 870 822 136 270
891 413 420 466 603 583 10 240 668 719
556 299 662 622 96 568 926 76 677 900
775 170 699 792 930 330 600 107 958 776
609 153 927 761 972 268 256 638 301 983
750 997 538 541 540 137 604 531 817 500
430 174 690 61 1004 764 928 396 199 409
358 867 856 982 345 504 281 910 269 458
756 226 519 312 471 375 551 875 355 325
20 45 60 814 209 806 212 1006 625 457
895 637 117 203 183 532 328 283 53 712
886 145 245 490 391 873 716 43 685 218
163 175 667 906 9 548 366 81 809 996
815 589 679 571 66 179 823 332 745 973
418 695 492 808 230 415 412 962 760 79
437 191 691 278 408 794 710 590 242 478
340 101 248 578 825 570 959 796 377 18
833 132 135 38 195 680 386 852 263 507
78 34 351 627 768 977 659 304 505 999
674 835 501 173 473 547 51 177 736 703
65 257 414 491 565 353 843 184 734 793
87 725 811 368 994 872 401 913 489 32
235 1003 723 317 421 384 759 481 635 19
753 339 534 326 1005 922 31 675 770 847
406 156 463 277 960 800 189 306 123 477
447 37 485 684 322 439 460 724 41 902
228 738 454 349 656 620 743 940 105 581
655 267 869 631 593 149 771 276 543 441
407 262 1000 67 689 524 757 839 846 128
727 868 706 850 288 44 974 883 666 47
673 272 503 956 670 613 889 393 425 90
141 238 717 948 722 975 644 162 772 405
451 448 992 862 840 573 215 499 92 279
610 857 849 169 661 382 687 819 225 417
Total data = 1019
Complete
sorry for the large amount of text, but i wanted to be thorough.
i want this(obviously not the same numbers, but just making it easier for myself to show you)
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
Enter to continue...
then it just repeats. till the numbers finish outputting from the text file.
Feb 12 '10 #3
reply
newb16 687 Contributor
The loop variable is i, but you always check for ct % something, that is constant throughout the loop.
Feb 12 '10 #4
reply
lolcheelol 25 New Member
that doesn't make alot of sense to me because my count is telling me how many numbers i have...
Feb 12 '10 #5
reply
newb16 687 Contributor
So why do you want to print next line after each number if total number of items divides by 15?
Feb 12 '10 #6
reply
lolcheelol 25 New Member
so it looks like this in the output
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
Enter to continue...
not
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
6 198 651 694 692 196 594 762 698 321 265 517 559 1010 648
Enter to continue...
does my question make sense? i know my actual coding is right because i'm getting the numbers, i just would like to know why the matrix isn't working
Feb 12 '10 #7
reply
newb16 687 Contributor
It's because _that_ part of coding that is responsible for making matrix _isn't_ right.
Feb 12 '10 #8
reply
lolcheelol 25 New Member
so your saying it should be i instead of ct? i'm not really getting what your saying.
Feb 12 '10 #9
reply
Sign in to post your reply or Sign up for a free account.
Similar topics
6 3332 Compile-time matrix dimension checking and template friend question by: Ben Ingram |last post by: Hi all, I am writing a template matrix class in which the template parameters are the number of rows and number of columns. There are a number of reasons why this is an appropriate tradeoff for my particular application. One of the advantages is that the _compiler_ can force inner matrix dimensions used in multiplication to agree. A _complie-time_ error will be triggered if you write A * B and the number of coluns in A does not equal the... C / C++ |
5 3808 Help on operator overload for something like matrix(row)(col) by: Jason |last post by: Hello. I am trying to learn how operator overloading works so I wrote a simple class to help me practice. I understand the basic opertoar overload like + - / *, but when I try to overload more complex operator, I get stuck. Here's a brief description what I want to do. I want to simulate a matrix (2D array) from a 1D array. so what I have so far is something like this: class Matrix C / C++ |
4 3739 ifstream problems by: hall |last post by: Hi. I ran across a bug in one of my problems and after spending some time tracking it down i found that the problem arose in a piece of code that essentially did this: ----------- ifstream in("in.txt"); if(!in) {cout << "error\n";} in.close(); if(!in) {cout << "error\n";} in.close(); if(!in) {cout << "error\n";} C / C++ |
3 2575 Problem with time() using g++ by: Mike Alexeev |last post by: Hi all, I have come across very strange behavior of the return value of the time() function. Below is the program to illustrate the problem: The value of NOW somehow changes after the call to the ifstream constructor. #include <iostream> #include <fstream> #include <time.h> C / C++ |
6 6585 global variable matrix by: memocan |last post by: #include <iostream> using namespace std; int x; //global variable matrix int main() { x= new float ; //initialize the size now } C / C++ |
20 5245 Matrix library where's the speed ? by: Frank-O |last post by: Hi , Recently I have been commited to the task of "translating" some complex statistical algorithms from Matlab to C++. The goal is to be three times as fast as matlab ( the latest) . I've used various techniques ( loop unrolling, loop jamming...) and tried some matrix libraries : newmat (slow for large matrix) , STL (fast but ..not usefull) , hand coding (brain consuming...), and recently Meschach... C / C++ |
5 12437 I want to create a std::ifstream using std::string by: Assertor |last post by: Hi, all. Is there any way to create an instance of std::ifstream using std::string. (through std::ifstream's constructor or assignment operator or iterator, etc...) i.e. std::string str = "this is a string"; std::ifstream ifs = str; //<----- this is a just pseudo code. C / C++ |
2 2840 adding input file into a matrix by: isaac2004 |last post by: hello i am trying to read an input file into a matrix, i have the following setup to get the file #include <iostream> #include <string> #include <fstream> using namespace std; int main() C / C++ |
1 1976
conflict matrix by: nurulshidanoni |last post by: Dear all, my algorith is like this while(mor students) read studentID countexam=0 while (more examination) read examcode examID =get ExamID (examCode) C / C++ |
11 8147 ifstream errors by: adramolek |last post by: So... I'm trying to get used to using C++ ifstream (or ofstream) instead of stdio (although I'm having second thoughts). Anyways, I want to be able to display a meaningful error message if ifstream fails to open a file, but nothing I read about ifstream says anything about a reliable place to get an error message. Using stdio I can simply do: FILE *f = fopen(filename, "rb"); if (!f) perror(filename); C / C++ |
9621
What is ONU? by: marktang |last post by: ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of... General |
10106
Maximizing Business Potential: The Nexus of Website Design and Digital Marketing by: jinu1996 |last post by: In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is... Online Marketing |
9914
Discussion: How does Zigbee compare with other wireless protocols in smart home applications? by: tracyyun |last post by: Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some... General |
8939
AI Job Threat for Devs by: agi2029 |last post by: Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea... Career Advice |
1 7463
Access Europe - Using VBA to create a class based on a table - Wed 1 May by: isladogs |last post by: The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will... Microsoft Access / VBA |
6717 Couldnt get equations in html when convert word .docx file to html file in C#. by: conductexam |last post by: I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();... C# / C Sharp |
5355 Trying to create a lan-to-lan vpn between two differents networks by: TSSRALBI |last post by: Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls... Networking - Hardware / Configuration |
1 4012 transfer the data from one system to another through ip address by: 6302768590 |last post by: Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system C# / C Sharp |
2 3611
How to add payments to a PHP MySQL app. by: muto222 |last post by: How can i add a mobile payment intergratation into php mysql website. PHP |
By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.
To disable or enable advertisements and analytics tracking please visit the page.