Thread: unable to access the elements of 2d array (T) created using valarray

  1. #1
    Registered User
    Join Date
    Sep 2016
    Posts
    1

    Red face unable to access the elements of 2d array (T) created using valarray

    I have created an array using valarray, in which every elements are complex type (CArray). I have created another array in which the elements are a pointer of the array created earlier, namely TArray.
    I have initialised the object T using some values. Now I am unable to access the individual elements of the object T. You can see the printf command in the code which is commented now. Please uncomment the line and write exact code.



    Attached Files Attached Files

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Compile with the -Wall option to see.
    Code:
    $ g++ -Wall main.cpp 
    main.cpp: In function ‘int main()’:
    main.cpp:56:34: warning: format ‘%lf’ expects argument of type ‘double’, but argument 2 has type ‘std::valarray<std::complex<double> >*’ [-Wformat=]
              printf("%lf \t", T[i][j]);
    For what it's worth, why aren't you using cout?

    Also, if you really must include the C API, then use the correct C++ names for those header files.
    #include <cstdio>
    #include <cmath>
    #include <cstdlib>
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 07-10-2016, 02:18 PM
  2. unable to access the file
    By deathslice in forum C Programming
    Replies: 4
    Last Post: 10-24-2015, 07:03 AM
  3. unable to access the file
    By deathslice in forum C++ Programming
    Replies: 4
    Last Post: 10-24-2015, 07:03 AM
  4. unable to access structure within a function
    By bluetxxth in forum C Programming
    Replies: 7
    Last Post: 02-17-2010, 03:52 AM
  5. pow on valarray....
    By m37h0d in forum C++ Programming
    Replies: 10
    Last Post: 07-29-2008, 10:59 AM

Tags for this Thread