473,378 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

atlsimpstr.h problem with mfc application

17
I have an MFC application (VS2005) with splitter window (one is the view other is a formview). you can select from the main menu different math operation on polynoms and polynoms shows on the formview. you can then calculate and the result is shown in the view. The class CalculsPolynoms above is working just fine for all operations except Multiplier(), the line myPoly->AfficherResultat(p_resultat, 11); brings me to AfficherResultat(...) and the pDoc->msgLine5 is breaking and bringing me to atlsimpstr.h line 812.
Unhandled exception at 0x78325e5a (mfc80ud.dll) in TP2.exe: 0xC0000005: Access violation reading location 0x00000064.


It works fine for all other functions except this one and I can not figure out why.

Any help would be greatly appreciated.




Expand|Select|Wrap|Line Numbers
  1. // **********************************CalculsPolynomes.cpp
  2. #include "StdAfx.h"
  3. #include "CalculsPolynomes.h"
  4.  
  5.  
  6.  
  7. CCalculsPolynomes::CCalculsPolynomes(void)
  8. {
  9. }
  10.  
  11. CCalculsPolynomes::~CCalculsPolynomes(void)
  12. {
  13. }
  14. void CCalculsPolynomes::Additionner(double* fx[6], double* gx[6])
  15. {
  16.     // Afficher les polynomes
  17.     // note: ces variables ne peuvent etre declarees const publiques ni static
  18.     // only static const integral data members can be initialized within a class
  19.     CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; 
  20.     CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); 
  21.     CTP2View *pView = (CTP2View *)pChild->GetActiveView();
  22.     CTP2Doc *pDoc = pView->GetDocument();
  23.  
  24.     pDoc->msgLine1 = "f(x) = ";
  25.     pDoc->msgLine2 = "+";
  26.     pDoc->msgLine3 = "g(x) = ";
  27.     pDoc->msgLine4 = "_________________________________________________";
  28.     pDoc->msgLine5 = "h(x) = ";
  29.  
  30.     for(int i = 5; i >= 0; --i)
  31.     {
  32.         // mettre le contenu du tableau f(x) dans un buffer
  33.         char bufferFx[_CVTBUFSIZE];
  34.         _gcvt(*fx[i], 12, bufferFx);
  35.         CString Fxi = (CString) bufferFx;
  36.  
  37.         // mettre i dans un buffer
  38.         char bufferi[_CVTBUFSIZE];
  39.         _itoa_s(i, bufferi, 10);
  40.         CString s_i = (CString) bufferi;
  41.  
  42.         // mettre le contenu du tableau g(x) dans un buffer
  43.         char bufferGx[_CVTBUFSIZE];
  44.         _gcvt(*gx[i], 12, bufferGx);
  45.         CString Gxi = (CString) bufferGx;
  46.  
  47.         // Afficher sur 2 lignes
  48.         pDoc->msgLine1 += Fxi;
  49.         pDoc->msgLine1 += "X";
  50.         pDoc->msgLine1 += s_i;
  51.  
  52.         pDoc->msgLine3 += Gxi;
  53.         pDoc->msgLine3 += "X";
  54.         pDoc->msgLine3 += s_i;
  55.  
  56.         // ajouter le signe +
  57.         if(i > 0)
  58.         {
  59.             pDoc->msgLine1 += "   +   ";
  60.             pDoc->msgLine3 += "   +   ";
  61.         }
  62.     }
  63.  
  64.     // Additonner
  65.     double resultat[6];
  66.     double* p_resultat[6];
  67.  
  68.     for(int i = 0; i < 6; ++i)
  69.     {
  70.         double f = *fx[i];
  71.         double g = *gx[i];
  72.         resultat[i] = f + g;
  73.         p_resultat[i] = &resultat[i];
  74.     }
  75.  
  76.     // Afficher le resultat
  77.     CCalculsPolynomes* myPoly = new CCalculsPolynomes();
  78.     myPoly->AfficherResultat(p_resultat, 6);
  79.  
  80.  
  81.  
  82. }
  83. void CCalculsPolynomes::Soustraire(double* fx[6], double* gx[6])
  84. {
  85.     // Afficher les polynomes
  86.     // note: ces variables ne peuvent etre declarees const publiques ni static
  87.     // only static const integral data members can be initialized within a class
  88.     CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; 
  89.     CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); 
  90.     CTP2View *pView = (CTP2View *)pChild->GetActiveView();
  91.     CTP2Doc *pDoc = pView->GetDocument();
  92.  
  93.     pDoc->msgLine1 = "f(x) = ";
  94.     pDoc->msgLine2 = "-";
  95.     pDoc->msgLine3 = "g(x) = ";
  96.     pDoc->msgLine4 = "____________________________________________________________";
  97.     pDoc->msgLine5 = "h(x) = ";
  98.  
  99.     for(int i = 5; i >= 0; --i)
  100.     {
  101.         // mettre le contenu du tableau f(x) dans un buffer
  102.         char bufferFx[_CVTBUFSIZE];
  103.         _gcvt(*fx[i], 12, bufferFx);
  104.         CString Fxi = (CString) bufferFx;
  105.  
  106.         // mettre i dans un buffer
  107.         char bufferi[_CVTBUFSIZE];
  108.         _itoa_s(i, bufferi, 10);
  109.         CString s_i = (CString) bufferi;
  110.  
  111.         // mettre le contenu du tableau g(x) dans un buffer
  112.         char bufferGx[_CVTBUFSIZE];
  113.         _gcvt(*gx[i], 12, bufferGx);
  114.         CString Gxi = (CString) bufferGx;
  115.  
  116.         // Afficher sur 2 lignes
  117.         pDoc->msgLine1 += Fxi;
  118.         pDoc->msgLine1 += " X";
  119.         pDoc->msgLine1 += s_i;
  120.  
  121.         pDoc->msgLine3 += Gxi;
  122.         pDoc->msgLine3 += " X";
  123.         pDoc->msgLine3 += s_i;
  124.  
  125.         // ajouter le signe +
  126.         if(i > 0)
  127.         {
  128.             pDoc->msgLine1 += "   +   ";
  129.             pDoc->msgLine3 += "   +   ";
  130.         }
  131.     }
  132.  
  133.     // Soustraire
  134.     double resultat[6];
  135.     double* p_resultat[6];
  136.  
  137.     for(int i = 0; i < 6; ++i)
  138.     {
  139.         double f = *fx[i];
  140.         double g = *gx[i];
  141.         resultat[i] = f - g;
  142.         p_resultat[i] = &resultat[i];
  143.     }
  144.  
  145.     // Afficher le resultat
  146.     CCalculsPolynomes* myPoly = new CCalculsPolynomes();
  147.     myPoly->AfficherResultat(p_resultat, 6);
  148.  
  149. }
  150. void CCalculsPolynomes::Multiplier(double* fx[6], double* gx[6])
  151. {
  152.     // Afficher les polynomes
  153.     // note: ces variables ne peuvent etre declarees const publiques ni static
  154.     // only static const integral data members can be initialized within a class
  155.     CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; 
  156.     CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); 
  157.     CTP2View *pView = (CTP2View *)pChild->GetActiveView();
  158.     CTP2Doc *pDoc = pView->GetDocument();
  159.  
  160.     pDoc->msgLine1 = "f(x) = ";
  161.     pDoc->msgLine2 = "+";
  162.     pDoc->msgLine3 = "g(x) = ";
  163.     pDoc->msgLine4 = "_________________________________________________";
  164.     pDoc->msgLine5 = "h(x) = ";
  165.  
  166.     for(int i = 5; i >= 0; --i)
  167.     {
  168.         // mettre le contenu du tableau f(x) dans un buffer
  169.         char bufferFx[_CVTBUFSIZE];
  170.         _gcvt(*fx[i], 12, bufferFx);
  171.         CString Fxi = (CString) bufferFx;
  172.  
  173.         // mettre i dans un buffer
  174.         char bufferi[_CVTBUFSIZE];
  175.         _itoa_s(i, bufferi, 10);
  176.         CString s_i = (CString) bufferi;
  177.  
  178.         // mettre le contenu du tableau g(x) dans un buffer
  179.         char bufferGx[_CVTBUFSIZE];
  180.         _gcvt(*gx[i], 12, bufferGx);
  181.         CString Gxi = (CString) bufferGx;
  182.  
  183.         // Afficher sur 2 lignes
  184.         pDoc->msgLine1 += Fxi;
  185.         pDoc->msgLine1 += "X";
  186.         pDoc->msgLine1 += s_i;
  187.  
  188.         pDoc->msgLine3 += Gxi;
  189.         pDoc->msgLine3 += "X";
  190.         pDoc->msgLine3 += s_i;
  191.  
  192.         // ajouter le signe +
  193.         if(i > 0)
  194.         {
  195.             pDoc->msgLine1 += "   +   ";
  196.             pDoc->msgLine3 += "   +   ";
  197.         }
  198.     }
  199.  
  200.     // Multiplier
  201.     double resultatM[11];
  202.     for(int i = 0; i < 11; ++i)
  203.     {
  204.         resultatM[i] = 0; // initialiser le tableau de resultats a zero
  205.     }
  206.     double* p_resultat[11];
  207.  
  208.     for(int i = 0; i < 6; ++i)
  209.     {
  210.         for(int j = 0; j < 6; ++j)
  211.         {
  212.             double f = *fx[i];
  213.             double g = *gx[j];
  214.             resultatM[i + j] += f * g; // additionner les degres, multiplier les coefficients
  215.             p_resultat[i + j] = &resultatM[i + j];
  216.         }
  217.     }
  218.  
  219.     // Afficher le resultat
  220.     CCalculsPolynomes* myPoly = new CCalculsPolynomes();
  221.     myPoly->AfficherResultat(p_resultat, 11);
  222. }
  223. void CCalculsPolynomes::Deriver(double* fx[6])
  224. {
  225.     // Afficher les polynomes
  226.     // note: ces variables ne peuvent etre declarees const publiques ni static
  227.     // only static const integral data members can be initialized within a class
  228.     CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; 
  229.     CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); 
  230.     CTP2View *pView = (CTP2View *)pChild->GetActiveView();
  231.     CTP2Doc *pDoc = pView->GetDocument();
  232.  
  233.     pDoc->msgLine1 = "f(x) = ";
  234.     pDoc->msgLine4 = "_________________________________________________";
  235.     pDoc->msgLine5 = "f'(x) = ";
  236.  
  237.     for(int i = 5; i >= 0; --i)
  238.     {
  239.         // mettre le contenu du tableau f(x) dans un buffer
  240.         char bufferFx[_CVTBUFSIZE];
  241.         _gcvt(*fx[i], 12, bufferFx);
  242.         CString Fxi = (CString) bufferFx;
  243.  
  244.         // mettre i dans un buffer
  245.         char bufferi[_CVTBUFSIZE];
  246.         _itoa_s(i, bufferi, 10);
  247.         CString s_i = (CString) bufferi;
  248.  
  249.         // Afficher sur 2 lignes
  250.         pDoc->msgLine1 += Fxi;
  251.         pDoc->msgLine1 += "X";
  252.         pDoc->msgLine1 += s_i;
  253.  
  254.         // ajouter le signe +
  255.         if(i > 0)
  256.         {
  257.             pDoc->msgLine1 += "   +   ";
  258.         }
  259.     }
  260.  
  261.     // Deriver
  262.     double resultat[5];
  263.     double* p_resultat[5];
  264.     for(int i = 0; i < 5; ++i)
  265.     {
  266.         resultat[i] = 0; // initialiser le tableau de resultats a zero
  267.     }
  268.  
  269.     for(int i = 0; i < 6; ++i)
  270.     {
  271.         if(i - 1 >= 0) // si le degre est plus grand ou egal a zero
  272.         {
  273.             double f = *fx[i];
  274.             resultat[i - 1] = i * f; // diminuer n de 1, multiplier n*coeffX
  275.             p_resultat[i - 1] = &resultat[i - 1];
  276.         }
  277.     }
  278.  
  279.     // Afficher le resultat
  280.     CCalculsPolynomes* myPoly = new CCalculsPolynomes();
  281.     myPoly->AfficherResultat(p_resultat, 5);
  282. }
  283. void CCalculsPolynomes::IntegraleNB(double* fx[6])
  284. {
  285.     // Afficher les polynomes
  286.     // note: ces variables ne peuvent etre declarees const publiques ni static
  287.     // only static const integral data members can be initialized within a class
  288.     CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; 
  289.     CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); 
  290.     CTP2View *pView = (CTP2View *)pChild->GetActiveView();
  291.     CTP2Doc *pDoc = pView->GetDocument();
  292.  
  293.     pDoc->msgLine1 = "f(x) = ";
  294.     pDoc->msgLine4 = "_________________________________________________";
  295.     pDoc->msgLine5 = "f(x) = ";
  296.  
  297.     for(int i = 5; i >= 0; --i)
  298.     {
  299.         // mettre le contenu du tableau f(x) dans un buffer
  300.         char bufferFx[_CVTBUFSIZE];
  301.         _gcvt(*fx[i], 12, bufferFx);
  302.         CString Fxi = (CString) bufferFx;
  303.  
  304.         // mettre i dans un buffer
  305.         char bufferi[_CVTBUFSIZE];
  306.         _itoa_s(i, bufferi, 10);
  307.         CString s_i = (CString) bufferi;
  308.  
  309.         // Afficher sur 2 lignes
  310.         pDoc->msgLine1 += Fxi;
  311.         pDoc->msgLine1 += "X";
  312.         pDoc->msgLine1 += s_i;
  313.  
  314.         // ajouter le signe +
  315.         if(i > 0)
  316.         {
  317.             pDoc->msgLine1 += "   +   ";
  318.         }
  319.     }
  320.  
  321.     // Integrale non bornee
  322.     double resultat[7];
  323.     double* p_resultat[7];
  324.     for(int i = 0; i < 7; ++i)
  325.     {
  326.         resultat[i] = 0; // initialiser le tableau de resultats a zero
  327.     }
  328.  
  329.     resultat[0] = 0; // augmenter n de 1, diviser n/coeffX
  330.     p_resultat[0] = &resultat[0];
  331.  
  332.     for(int i = 0; i < 6; ++i)
  333.     {
  334.             double f = *fx[i];
  335.             resultat[i + 1] = f / (i + 1); // augmenter n de 1, diviser n/coeffX
  336.             p_resultat[i + 1] = &resultat[i + 1];
  337.     }
  338.  
  339.     // Afficher le resultat
  340.     CCalculsPolynomes* myPoly = new CCalculsPolynomes();
  341.     myPoly->AfficherResultat(p_resultat, 7);
  342. }
  343.  
  344. void CCalculsPolynomes::AfficherResultat(double* result[], int size)
  345. {
  346.  
  347.     // Afficher les polynomes
  348.     // note: ces variables ne peuvent etre declarees const publiques ni static
  349.     // only static const integral data members can be initialized within a class
  350.     CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; 
  351.     CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); 
  352.     CTP2View *pView = (CTP2View *)pChild->GetActiveView();
  353.     CTP2Doc *pDoc = pView->GetDocument();
  354.  
  355.     double resultat[6];
  356.     for(int i = 0; i < 6; ++i)
  357.     {
  358.         resultat[i] = 0;
  359.     }
  360.  
  361.     // verifie si le resultat total est zero
  362.     double k = 0;
  363.  
  364.     for(int i = 0; i < size; i++)
  365.     {
  366.         resultat[i] = *result[i]; // store dans resultat[i] le contenu de result[i]
  367.         k += resultat[i]; // additionne les valeurs de resultat
  368.     }
  369.  
  370.     // si le resultat total est zero, affiche zero
  371.     if(k == 0)
  372.     {
  373.         pDoc->msgLine5 += "  0"; // THIS LINE BREAKS AND BRINGS ME TO atlsimpstr.h line 812
  374.  
  375.     }
  376.     // si le resultat est different de zero
  377.     else
  378.     {
  379.         // afficher le resultat
  380.         for(int i = size -1; i >= 0; i--)
  381.         {
  382.             if(result[i] !=0)
  383.             {
  384.                 // mettre le contenu du tableau h(x) dans un buffer
  385.                 char bufferHx[_CVTBUFSIZE];
  386.                 _gcvt(resultat[i], 11, bufferHx);
  387.                 CString Hxi = (CString) bufferHx;
  388.  
  389.                 char bufferi[_CVTBUFSIZE];
  390.                 _itoa_s(i, bufferi, 10);
  391.                 CString s_i = (CString) bufferi;
  392.  
  393.                 // Afficher sur ligne
  394.                 pDoc->msgLine5 += Hxi;
  395.                 pDoc->msgLine5 += " X";
  396.                 pDoc->msgLine5 += s_i;
  397.  
  398.                 // ajouter le signe +
  399.                 if(i > 0)
  400.                 {
  401.                     pDoc->msgLine5 += "   +   ";
  402.                 }
  403.             }
  404.         }
  405.     }
  406.  
  407. }
  408. int CCalculsPolynomes::CountArray(double* result[])
  409. {
  410.     int i = 0;
  411.     while(result[i] != 0X00)
  412.     {
  413.         i++;
  414.     }
  415.     //return i;
  416.     return(sizeof(result) / sizeof(*result))-1;
  417. }
  418.  
  419.  
  420. // ***********************************************CalculsPolynomes.h
  421. #pragma once
  422. #include "TP2View.h"
  423. #include "MyForm.h"
  424. #include "resource.h"
  425.  
  426.  
  427. class CCalculsPolynomes
  428. {
  429. public:
  430.     CCalculsPolynomes(void);
  431. public:
  432.     ~CCalculsPolynomes(void);
  433.  
  434.     void Additionner(double* fx[6], double* gx[6]);
  435.     void Soustraire(double* fx[6], double* gx[6]);
  436.     void Multiplier(double* fx[6], double* gx[6]);
  437.     void Deriver(double* fx[6]);
  438.     void IntegraleNB(double* fx[6]);
  439.     void IntegraleBDirecte(double* fx[6]);
  440.     void IntegraleBTrapeze(double* fx[6], double* pas);
  441.     void Evaluer(double* fx[6]);
  442.     void RacinesDirecte(double* fx[6]);
  443.     void RacinesBissection(double* fx[6]);
  444.     void ExtremumsDirecte(double* fx[6]);
  445.     void AfficherResultat(double* result[], int size);
  446.     int CountArray(double* result[]);
  447.  
  448.  
  449.  
  450.  
  451. };
  452.  
  453.  
  454.  
full project is available at http://yolaine.biz/TP2.zip if needed

thanks in advance
Mar 16 '08 #1
1 1071
weaknessforcats
9,208 Expert Mod 8TB
What is your question?

Please read the posting guidelines.
Mar 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Justin Lazanowski | last post by:
Cross posting this question on the recommendation of an I have a .NET application that I am developing in C# I am loading information in from a dataset, and then pushing the dataset to a grid,...
3
by: Ray | last post by:
I am having my first experience using BLOB as a row in a table. I am using it to insert graphics for labels we print. I have no problem inserting into and select from the table. The graphic is...
7
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the...
0
by: Brano | last post by:
Hi all, I have a asp.net website that has been live for about 2 weeks now and there were no problems with it. I have got a new server that is Win 2003 IIS 6.0 I have moved my application onto...
8
by: Nate | last post by:
I am running on Window 2003. I have a website built in ASP.NET 2.0. I need to have a Virtual Directory running an application in 1.1. I have configured each in its own Application Pool. The 1.1...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
1
by: jffialho | last post by:
Hi there, Could someone help me with, this error: I am trying to deploy some applications to a web server with II 6.0, which contains a SharePoint Portal and a ASP .NET application. So far so...
12
by: Dilip | last post by:
Hi All I have a server based C# console application. This application must hide its console window when its launched out on the field. So I dutifully P/Invoke'd FindWindow/ShowWindow...
5
by: YouPoP | last post by:
I have an MFC application (VS2005) with splitter window (one is the view other is a formview). you can select from the main menu different math operation on polynoms and polynoms shows on the...
1
by: Bhrionn | last post by:
Hello World, I am working on implementing a build for my companies application. The scenario implemeted is producing the error: ‘Class does not support automation or does not support expected...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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 manage ads & tracking page.