Click here to Skip to main content
       

C / C++ / MFC

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
AnswerRe: Trying to call function from parallel classes...member«_Superman_»20 Jun '09 - 17:07 
You could try the same trick done by ATL.
Make the CMainFrame class a template class.
Pass the class derived from CMainFrame as the template parameter to CMainFrame.
 
Something like this.
 
class COutputWnd : public CMainFrame<COutputWnd>
{
};
 
template<typename T>
class CMainFrame : public CFrameWnd
{
    T m_OutputWnd;
};

 
«_Superman
I love work. It gives me something to do between weekends.

GeneralRe: Trying to call function from parallel classes...mvpStephen Hewitt20 Jun '09 - 21:51 
This is known as the Curiously recurring template pattern[^].
 
Steve

GeneralRe: Trying to call function from parallel classes...mvpled mike22 Jun '09 - 4:45 
Never seen that before! I have used it for years I believe in creational patterns like factory. I'd have to go scare up some old code to verify that but I'm pretty sure.
QuestionDownloading files from web sites like rapidshare!memberHadi Dayvary20 Jun '09 - 9:58 
Hi
I have written a downloader program that can download files from internet (with resume support).
But after I pass the file address and username and password of my account in rapidshare it can not download it, it just download a html file:
 m_pHttpConnection = m_InternetSession.GetHttpConnection(sServer, nPort, sUser, sPassword);
also this function returns FALSE :
file.SendRequest(NULL);
 
Does anybody know how to pass username and password to rapisdhare or other sharing web sites?
Regards
Hadi
 
www.logicsims.ir

AnswerRe: Downloading files from web sites like rapidshare!memberStuart Dootson20 Jun '09 - 14:24 
IIRC, the GetHttpConnection call lets you do URL authentication[^]. I suspect sites like rapidshare use something like basic authentication, as illustrated by this page[^], where username and password are passed in request headers.
 
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

GeneralRe: Downloading files from web sites like rapidshare!memberHadi Dayvary22 Jun '09 - 10:12 
Thank you for your answer,
I read those article, semms to be good, I changed my code for this way, but it did not work.
It just downloads a HTML file! not the file itself!
Do you have any other idea, is there any help in rapidshare for this? I searched a lot but did not find anything helpful!
Thanks
 
www.logicsims.ir

GeneralRe: Downloading files from web sites like rapidshare!memberStuart Dootson22 Jun '09 - 10:23 
Try monitoring the HTTP transactions using Fiddler[^] - it's a splendid debugging tool when doing low-level HTTP stuff.
 
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

QuestionClistCtrl w/Popup Menu - Wrong Menu Item Returnedmemberjon_fallon20 Jun '09 - 9:47 
A popup menu has been created that displays a list of options for insertion into a Item>SubItem cell. The menu comes up fine, but the return value is either 0 or 1, despite the flag being set to return the menu item. It was used in a dialog only previously, and think that the hWnd is the culprit on returning the wrong item number.
 
Any suggestions?
 
Many thanks in advance.
<code>void CTab2::OnRclickListCtrl(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int i, nItem, nSubItem, nSel;
CString s;
POINT point;
HMENU hMenu = ::CreatePopupMenu();
CRect rect;
 
LPNMITEMACTIVATE temp = (LPNMITEMACTIVATE) pNMHDR;
nItem = temp->iItem;
nSubItem = temp->iSubItem;
if( nSubItem == -1 || nItem == -1 ) return ;
 
if (NULL != hMenu && nSubItem == 2 && nItem < lLayer ) {
for ( i = 0; i < lBulkMax; i++ ) {
::AppendMenu ( hMenu, MF_STRING, 1, sBulk[i].desc );
}
 
point.x = 200; point.y = 200;
ClientToScreen(&point);
 
nSel = ::TrackPopupMenuEx(hMenu,
TPM_LEFTALIGN | TPM_RETURNCMD | TPM_LEFTBUTTON,
point.x,
point.y,
temp->hdr.hwndFrom,
NULL);
::DestroyMenu(hMenu);
s.Format ("item selected is number %d", nSel);
AfxMessageBox ( s );
if ( nSel > 0 && nSel <= lBulkMax ) {
m_cListCtrl.SetItemText( nItem, nSubItem, sBulk[ nSel - 1 ].desc );
}
 
}
/*
typedef struct tagNMHDR
{
HWND hwndFrom;
UINT idFrom;
UINT code; // NM_ code
} NMHDR;
typedef NMHDR FAR * LPNMHDR;
 
*/
 
*pResult = 0;
}

AnswerRe: ClistCtrl w/Popup Menu - Wrong Menu Item ReturnedmemberRoger Allen21 Jun '09 - 13:37 
The third parameter to AppendMenu in your loop is 1. This gives all the mnu options this ID. If you cancel the menu you will get 0 returned, any option you select will return 1. You need to add each item to the menu with a different id number.
 
Try changing it to i+1
 
If you vote me down, my score will only get lower

GeneralRe: ClistCtrl w/Popup Menu - Wrong Menu Item Returnedmemberjon_fallon22 Jun '09 - 2:35 
Thanks. A single append line was clipped from another program that had hard-coded ids, and neglected to change it to a loop based id.
QuestionWrapper function for sprintf, strcpy, strcat?memberdipuks20 Jun '09 - 7:56 
Hello
 
I am working on VS2003 and using the above mentioned functions, but the compiler gives me warning saying those functions are #pragma depreciated.
 
I know VS2008 has functions like sprintf_s, but unfortunately i will not be able to upgrade to 2008.
 
So now i want to use a wrapper function around sprintf, which will do the additional work that sprintf_s will do and there by making sure that i call sprintf only once.
 
This new wrapper function should be able to check for buffer over run and then i will call sprintf inside this function.
 
What it will do is, it will make sure that, i only need to call sprintf once and that will bring down compiler warning to just one.
 
Is anyone aware of such a wrapper function? Or can anyone help write a wrapper?
 
Thanks in advance.
AnswerRe: Wrapper function for sprintf, strcpy, strcat? [modified]mvpLuc Pattyn20 Jun '09 - 8:45 
Hi,
 
here are some thoughts and pointers:
 
1. for a very long time there have been some string functions that limit the number of bytes written to a buffer. Depending on vendor and compiler they got different names, most often things such as snprintf, strncat, strncpy, ... You really don't need VS2008 to get some of those. The main problem is the names and signatures have not been standardized successfully,
so choose one and locate it or implement it.
 
2.
snprintf-like stuff from Microsoft:
http://msdn.microsoft.com/en-us/library/2ts7cx93(VS.71).aspx[^]
http://msdn.microsoft.com/en-us/library/ms647541(VS.85).aspx[^]
 
3.
one needs the "variable arguments" technology to wrap something that takes a variable number of arguments. However accepting and passing on a list of arguments is a bit tricky, there is a special vsnprintf function[^] for that purpose.
As well as this one[^].
 
4.
if not found, strncpy and strncat can be written from scratch easily, at least when there is no need for maximum performance. They basically are just a loop copying one byte at a time. (Strcat needs to find the end of the current content first, either use another loop or strlen).
 
5.
the main problem is all these safe functions need the size of the destination buffer, which can be handled in two ways:
(a) when the only purpose is to avoid compiler warnings (sprintf, strcpy, ... being deprecated now), just pass a very large number (or implement the convention that zero means infinite)
(b) look in the source code (where sprintf used to be) for the buffer size, and pass that.
 
Either way, the source code needs to be changed at every location where the safe version has to be used instead of the unsafe version.
 
6.
possible extra safety: the safe function could implement a simple check on the destination pointer; in my experience it is useful to reject any address in the range [0, 1023] since that typically is what you get when a class/struct pointer is zero. You could use an assert to report a problem, and/or return null.
 
Smile | :)
 
Luc Pattyn [Forum Guidelines] [My Articles]

DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
modified on Saturday, June 20, 2009 2:55 PM

AnswerRe: Wrapper function for sprintf, strcpy, strcat?mvpStephen Hewitt20 Jun '09 - 21:54 
I turn off these warnings. Microsoft is not in a position to declare standard C++ functions deprecated.
 
Steve

GeneralWelcome in the CP's Memorable Quotes list.mvpCPallini21 Jun '09 - 0:22 
Welcome [^] Steve.
Big Grin | :-D
 
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke

[My articles]

GeneralRe: Welcome in the CP's Memorable Quotes list.mvpStephen Hewitt21 Jun '09 - 3:34 
I see I'm in good company.
 
Steve

AnswerRe: Wrapper function for sprintf, strcpy, strcat?mvpDavidCrow22 Jun '09 - 4:21 
dipuks wrote:
I am working on VS2003 and using the above mentioned functions, but the compiler gives me warning saying those functions are #pragma depreciated.
 
I know VS2008 has functions like sprintf_s, but unfortunately i will not be able to upgrade to 2008.

 
If the compiler is telling you they are deprecated, then is it also telling you what to use instead? I find it hard to believe that the compiler would know enough to complain, yet not provide any means by which to correct the problem.
 
In any case, you might have to use _CRT_SECURE_NO_WARNINGS.
 

"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons


QuestionLink ErrorsmemberMuhammad Hassan Haider20 Jun '09 - 7:25 
I have written a small dialog based application which uses Cximage class to achieve compression. The program works fine but i have a problem which arises once i use static MFC library to compile the program. I need to use the program on other computers but it fails to work because of the problem.
I get compiler errors LNK2005 like
 
MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _fclose already defined in libcmt.lib(fclose.obj)
these are 35 in total
 
I read from a forum to put libcmt.lib in Ignore Specific Library tab. The things works
but then i get 3 errors related to LNK2001 like
 
1>cximage.lib(ximaenc.obj) : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification
1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
 
I even tried to use the ForceLib.h file as described in msdn forums. But to no avail. Can anyone help.
The code i need to compile is present on this website by name Image Compressor.
Regards
Hassan
AnswerRe: Link ErrorsmemberStuart Dootson20 Jun '09 - 14:38 
Sounds like you're using two different versions of the C run-time - MSVCRTD is a debug, dynamic link version. libcmt is a release, static link version. So, different bits of your project have different C++->Code Generation->Runtime Library options. I suspect that the way CxImage has been built is disagreeing with your project.
 
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

AnswerRe: Link Errorsmember«_Superman_»20 Jun '09 - 17:14 
Try giving /FORCE:MULTIPLE in the properties in
Project Properties -> Configuration Properties -> Linker -> Command Line -> Additional Options.
 
«_Superman
I love work. It gives me something to do between weekends.

QuestionTrying to create a Tool bar using the class CToolBarmemberBobInNJ20 Jun '09 - 7:02 
I am attempting to understand how to use the class CToolBar. Therefore, I wrote some sample
code that is suppose to create a tool bar. However, the tool bar is not being displayed. The
definition of the tool bar is in my class CMainWindow and is defined as follows:
CToolBar toolBar;
 
Here is the code that I use to create the tool bar:
 

BOOL status1 = toolBar.Create( this );
BOOL status2 = toolBar.LoadToolBar( IDR_TOOLBAR );
toolBar.SetButtonStyle( 0, TBBS_CHECKBOX );
toolBar.SetButtonStyle( 1, TBBS_CHECKBOX );
toolBar.SetButtonStyle( 2, TBBS_CHECKBOX );
toolBar.SetButtonStyle( 3, TBBS_CHECKBOX );
toolBar.SetButtonStyle( 4, TBBS_CHECKBOX );
toolBar.SetButtonStyle( 5, TBBS_CHECKBOX );
 
const UINT idArray[] = {
IDM_LINES, IDM_RECTANGLES, IDM_ELLIPSES,
IDM_ENLARGE, IDM_ORG, IDM_RESET
};
 
toolBar.SetButtons( idArray, 6 );
toolBar.ShowWindow( SW_SHOW );
toolBar.SetSizes( CSize(48,42 ), CSize( 40, 19 ) );

 
The return value from Create is 1 and the return value from LoadToolBar is 1. The return value from SetButtons is 1. The return value from ShowWindow is 16. I am interpreting these return values to mean that all went well. However, the tool bar is not being displayed. I am hoping that somebody out there can tell me what I am doing wrong.
 
Thanks
 
Bob
Questiontext on a toolbar button not vertically centeredmemberAnantheswarG20 Jun '09 - 4:29 
hi i have a toolbar with buttons added
 
btnBookmark.idCommand = idCommand;
btnBookmark.fsState = TBSTATE_ENABLED;
btnBookmark.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE| BTNS_SHOWTEXT;// | BTNS_DROPDOWN;//| ;
btnBookmark.dwData = 0;
btnBookmark.iString = (INT_PTR)cstrKeyName.GetBuffer();
btnBookmark.iBitmap = -2;
 
but the text on the toolbar buttons is a bit high its not vertically centere
QuestionRead coefficients of linear equations into 2d arraymemberOmar Al Qady20 Jun '09 - 1:51 
Hi,
I'm working on a program that reads linear equations from a file such as those:
3x+2y-2.5z=9
-2x+9y+12z=23.4
4.2x-7y+9.6z=45.3
 
The file is supposed to contain n equations with n variables which I would read into a 2d dynamic array of doubles and then I'm supposed to solve the resulting matrix using Gauss's method. I've already implemented Gauss's method but I can't figure out when reading from file how to get only the numbers and the signs for example from the above equations I'm supposed to have the following in the array:
[+3][+2][-2.5]
[-2][+9][+12]
[+4.2][-7][+9.6]
 
I need the numbers after the equal sign to be stored in a separate n sized array as well.
 
If anyone has any ideas I'd really appreciate it Smile | :)
AnswerRe: Read coefficients of linear equations into 2d arraymemberchandu00420 Jun '09 - 2:01 
here i have a rough idea.
 
Omar Al Qady wrote:
3x+2y-2.5z=9-2x+9y+12z=23.44.2x-7y+9.6z=45.3

 
fscanf(fp,"%fx%fy%fz=5f",el1,el2,el3,el4);
 
should fetch you the required values into el1....el4.
try it out if it does not work we shall find out some other way.
good luck.
 
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.

GeneralRe: Read coefficients of linear equations into 2d arraymemberOmar Al Qady20 Jun '09 - 2:23 
The problem is that the variables aren't always x,y,z because the program should solve n equations with n variables, so they can be more than 3 or less, so I can't assume when reading the data it's only three variables.
I thought about something but I just can't implement, if I can read double by double into the array until I reach the equal sign then the double after is read into a different n sized array for the solutions, and when a new line is started I'd repeat the process in the next row of the 2d array.
I don't know if what I said above is even possible but if you can help me in implementing it I'd be grateful Smile | :)
 
Thanks for your reply Smile | :) and thanks in advance for any additional help you can give Smile | :)
GeneralRe: Read coefficients of linear equations into 2d arraymemberchandu00420 Jun '09 - 2:41 
if i understood your problem correctly,
then open the src file in read mode,
open another dest file in write mode,
copy character by character from src file to dest file.
if any alphabet is read, then write some standard character like ':' or any other char which is not in your expressions.
for example, 3x-2y+7z-3q=2.5 will become 3:-2:+7:-3:=2.5
then do something like
fscanf("%f:",&el1);
still some more logics we may have to implement like finding size of the 2d array etc.
we can work around them subsequently if u have understood till here.
 
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.

GeneralRe: Read coefficients of linear equations into 2d arraymvpLuc Pattyn20 Jun '09 - 2:46 
I don't think so.
First you don't need to create a file in order to read and parse an existing file.
Second, there is no guarantee the variables are ordered the same in every line and/or a coefficient of zero gets mentioned at all, so one really has to check the variable names.
 
All it takes is reading the characters of a line, then parse it into numbers, identifiers and operators.
 
Smile | :)
 
Luc Pattyn [Forum Guidelines] [My Articles]

DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.

GeneralRe: Read coefficients of linear equations into 2d arraymemberchandu00420 Jun '09 - 2:54 
Luc Pattyn wrote:
there is no guarantee the variables are ordered the same in every line

 
yes it is a valid point. even iam thinking in that perspective.i assumed the same sequence of variables while posting.
let the op confirm this point, i.e. if the same sequence is guarenteed or not..
 
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.

GeneralRe: Read coefficients of linear equations into 2d arraymemberOmar Al Qady20 Jun '09 - 3:16 
No the sequence is not constant and there might be coefficients of 0 which would the variable would not be at all present in the line.
GeneralRe: Read coefficients of linear equations into 2d arraymemberchandu00420 Jun '09 - 3:27 
fine then,
i will also work aroundit. as of now, do as luc pattyn suggested.
if you get the solution please specify it here.
otherwise i shall attempt it on monday.
all the best.
 
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.

GeneralRe: Read coefficients of linear equations into 2d arraymemberOmar Al Qady20 Jun '09 - 3:39 
OK then, thank you all for your help and I'll post here if I get it done Smile | :)
GeneralRe: Read coefficients of linear equations into 2d arraymemberTheArchitectualizer20 Jun '09 - 4:06 
Hmm, How about a RegExp? You could scrub data into a tonenized string then convert it to an array.
 
There is an open source mathematics program called 'sage', I would look atthe aproach they are implimenting. Also, you might find other good ideas by searching for OpenML. There are many examples supported by many frameworks.
GeneralRe: Read coefficients of linear equations into 2d arraymemberOmar Al Qady20 Jun '09 - 4:22 
I'll look into the source of 'sage' then and see if it's of any help.
The other things you mentioned I'm afraid I don't understand as I am not a very advanced programmer (yet I hope Smile | :) ).
Thanks for replying Smile | :)
AnswerRe: Read coefficients of linear equations into 2d arraymembersuthakar5620 Jun '09 - 2:10 
hi,
i have a small idea that, based on the ascii value you can separte the number,x,y,z and = sign.For x,y,z you just read each character and check with in the range(ie 120,121,122,61 for x,y,z,= respectively) and you can use isalpha() for whether the reading data is albhapet or numeric.
 

regards,
Suthakar
GeneralRe: Read coefficients of linear equations into 2d arraymemberOmar Al Qady20 Jun '09 - 2:33 
So maybe I'd read each line into a string, and then go through it char by char checking for letters and = and if not I'd store in the 2d double array and after I find a letter I move to the next column, and so on till the = and store what's after it in the solutions array. I'm getting a vague idea now of how to do this, but are the signs and decimal points also readable and convertible in the same way? For example when reading -2.9 , the - & . wouldn't fall in the range for the letters and the = but can I convert them along with the numbers into a double??
GeneralRe: Read coefficients of linear equations into 2d arraymvpLuc Pattyn20 Jun '09 - 2:49 
yes, that is about right, except you are not sure the variables will appear in the same order every time (one even could be omitted when its coefficient happens to be zero). So you must parse the line into numbers, identifier names and operators; then keep an array of known identifiers (=variable names) which leads you to the right column in the 2D matrix.
 
Smile | :)
 
Luc Pattyn [Forum Guidelines] [My Articles]

DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.

GeneralRe: Read coefficients of linear equations into 2d arraymemberOmar Al Qady20 Jun '09 - 2:58 
I was just thinking about what would happen if a coefficient is zero and I just freaked out and thought I'd skip it before your reply Big Grin | :-D But I'll try your way and see how it goes Smile | :)
 
Thanks a lot Smile | :)
AnswerRe: Read coefficients of linear equations into 2d arraymember«_Superman_»20 Jun '09 - 2:45 
First read the file one line at a time.
You could use ifstream::getline[^] for this.
 
Then you could use the strtok_s function[^] to separate the coefficients.
 
«_Superman
I love work. It gives me something to do between weekends.

GeneralRe: Read coefficients of linear equations into 2d arraymemberOmar Al Qady20 Jun '09 - 3:02 
Yes I think I'll try getline() and save each line into a string in a string array, and then parse it like I was advised to do above and save the coefficients in the 2d array while checking for variable in the variable array each time. I think this would be the way to go Smile | :)
 
Thanks for replying Smile | :)
GeneralRe: Read coefficients of linear equations into 2d arraymemberTheArchitectualizer20 Jun '09 - 4:09 
Oh yeah, forgot to mention another idea. Create a Red / Black tree from the code. Look at examples for expanding lambda expressions.
GeneralRe: Read coefficients of linear equations into 2d arraymemberOmar Al Qady20 Jun '09 - 4:44 
I don't know about this either, so I'll try working with the hints and ideas from above and if it doesn't work out I'll research this and work on it Smile | :)
 
Thanks for your ideas Smile | :)
GeneralRe: Read coefficients of linear equations into 2d arraymemberchandu00421 Jun '09 - 18:22 
hope your problem is solved.
i did some paperwork onit yesterday and got some ideas.
do you require any more discussion on that today?
 
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.

GeneralRe: Read coefficients of linear equations into 2d arraymemberOmar Al Qady22 Jun '09 - 0:18 
Actually I was very busy yesterday, so I didn't have time to implement the ideas that I got from the discussion here yet but I'll start working on it today and let you know how it works out. Post your ideas anyway they might help me now Smile | :) I need all the help I can get Smile | :)
Thank you for taking the time to think about the problem Smile | :)
GeneralRe: Read coefficients of linear equations into 2d arraymemberchandu00422 Jun '09 - 1:32 
so, kindly confirm these points for me as per my understanding of the problem.
1. the coefficients may be 0 means, one of the variables may be absent in the expression.
2. the sequence of the variables may change.
3. Will a variable be only 1 character or may be more?
4. what will be the maximum n? (size of expression/number of expressions)
because,
the solution i have sketched are dependant onthese inputs.
 
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.

GeneralRe: Read coefficients of linear equations into 2d arraymemberOmar Al Qady22 Jun '09 - 9:29 
1. Yes, that's possible, but a friend gave an idea of initializing the whole 2d array to equal zero, so when a variable isn't found in an equation the value isn't changed and would be correct for further calculations.
2. Yes, the sequence may change from one equation to another.
3. Variables could be one or more character so I'll just save them in an array of strings.
4. No maximum size was stated, but I don't think that matters as long as the arrays are dynamic, or does it?? D'Oh! | :doh:
GeneralRe: Read coefficients of linear equations into 2d arraymemberchandu00422 Jun '09 - 19:33 
yes,
my ideas seem to resemble with those you got yourself or my be from our friends here.
go ahead, and you will surely achieve it.
we will also co operate withyou.
 
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.

GeneralRe: Read coefficients of linear equations into 2d arraymemberOmar Al Qady23 Jun '09 - 0:15 
Working on it now .... Big Grin | :-D
AnswerRe: Read coefficients of linear equations into 2d arraymvpDavidCrow22 Jun '09 - 4:41 
Omar Al Qady wrote:
If anyone has any ideas I'd really appreciate it

 
Here's a half-baked one:
 
void main( void )
{
    char szTemp[16],
         *pInput[3] = { "3x+2y-2.5z=9", 
                        "-2x+9y+12z=23.4", 
                        "4.2x-7y+9.6z=45.3" };
 
    int x = 0;
    double d1, d2, d3;
 
    for (char *p = pInput[0]; p && *p != '\0'; p++)
    {
        if (isalpha(*p))
        {
            szTemp[x] = '\0';
            // use atof(szTemp) here
            x = 0;
        }
        else if ('=' == *p)
            break;
        else
        {
            szTemp[x] = *p;
            x++;
        }
    }
}

 

"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons


GeneralRe: Read coefficients of linear equations into 2d arraymemberOmar Al Qady23 Jun '09 - 0:14 
Good ideas, I'll try to incorporate them into my solution Smile | :)
Thanks Smile | :)
Questionread a file using Readfile()memberrahuljin20 Jun '09 - 0:31 
hi,
 
i want to know that how to read a file line by line using Readfile() function ??
 
also please tell me how to get the address of a text file which is in the same folder as the program ? i want to open it in the program, but the folder location may change.
 
thanks
 
rahul
AnswerRe: read a file using Readfile()memberchandu00420 Jun '09 - 0:36 
rahuljin wrote:
also please tell me how to get the address of a text file which is in the same folder as the program ? i want to open it in the program, but the folder location may change

 
in most of the cases, though the folder location changes, the files available inthe folder same as the exe can be accessed direcly by its name. i mean no path need to be specified.
 
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.

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


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid