CStringArray pointer problem

I am trying to use a CStringArray pointer, but everytime I do, I get a 
runtime error.

	CStringArray *ptmpStr;    //in class header file of dialog

	ptmpStr->SetSize(2,40);


If just use a regular CStringArray variable, it works fine.

	CStringArray tempString;	//in class header file of dialog
	
	tempString.SetSize(2,40);

What am I doing wrong?

	Roger	
0
nospam2791 (369)
5/25/2005 3:02:41 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
1190 Views

Similar Articles

[PageSpeed] 40

Are you sure that the poitner is acutally pointing to an instance of the 
CStringArray class:

ptmpStr = new CStringArray;
ptmpStr->SetSize(2, 40);

Remember that you will need to call delete on the pointer, otherwise you'll 
have a memory leak.

David


"Z.K." <nospam@nospam.net> wrote in message 
news:OmllNrTYFHA.1368@tk2msftngp13.phx.gbl...
>I am trying to use a CStringArray pointer, but everytime I do, I get a 
>runtime error.
>
> CStringArray *ptmpStr;    //in class header file of dialog
>
> ptmpStr->SetSize(2,40);
>
>
> If just use a regular CStringArray variable, it works fine.
>
> CStringArray tempString; //in class header file of dialog
>
> tempString.SetSize(2,40);
>
> What am I doing wrong?
>
> Roger 


0
5/25/2005 3:08:09 PM
Thanks, that fixed it.

	Roger

David Topham wrote:
> Are you sure that the poitner is acutally pointing to an instance of the 
> CStringArray class:
> 
> ptmpStr = new CStringArray;
> ptmpStr->SetSize(2, 40);
> 
> Remember that you will need to call delete on the pointer, otherwise you'll 
> have a memory leak.
> 
> David
> 
> 
> "Z.K." <nospam@nospam.net> wrote in message 
> news:OmllNrTYFHA.1368@tk2msftngp13.phx.gbl...
> 
>>I am trying to use a CStringArray pointer, but everytime I do, I get a 
>>runtime error.
>>
>>CStringArray *ptmpStr;    //in class header file of dialog
>>
>>ptmpStr->SetSize(2,40);
>>
>>
>>If just use a regular CStringArray variable, it works fine.
>>
>>CStringArray tempString; //in class header file of dialog
>>
>>tempString.SetSize(2,40);
>>
>>What am I doing wrong?
>>
>>Roger 
> 
> 
> 
0
nospam2791 (369)
5/25/2005 6:37:35 PM
"A runtime error". Come on. THERE IS A VERY SPECIFIC ERROR MESSAGE GENERATED! TELL US WHAT
IT IS! We can't really answer questions that are this vague. "My program doesn't work.
Tell me what I did wrong". There is a lot of very detailed information availble. For
example, enter the debugger. Examine the variable. Look at the function that failed. Look
at how it was called. Look at its parameters. Display the value of ptmpStr. Any of these
actions would give us a lot of information which would help us answer the question.

The most obvious suggestion is that you have not actually set a valid pointer to a
CStringArray in ptmpStr, so what you get is an access fault at an invalid address, because
the pointer has a bogus value. Of course, telling us what function this occurred in, and a
bit of information about the stack backtrace, would help a lot.
				joe

On Wed, 25 May 2005 08:02:41 -0700, "Z.K." <nospam@nospam.net> wrote:

>I am trying to use a CStringArray pointer, but everytime I do, I get a 
>runtime error.
>
>	CStringArray *ptmpStr;    //in class header file of dialog
>
>	ptmpStr->SetSize(2,40);
>
>
>If just use a regular CStringArray variable, it works fine.
>
>	CStringArray tempString;	//in class header file of dialog
>	
>	tempString.SetSize(2,40);
>
>What am I doing wrong?
>
>	Roger	

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
5/28/2005 9:22:31 PM
Reply:

Similar Artilces:

Problem with Printing
Am trying to print out a 'tent' card in Publisher. In draft it comes out fine and folds perfectly but when I use glossy photo paper the two parts do not line up and overlap when folded. Suggest this is coz the thicker photo paper is feeding through more slowly - any ideas? Thank you. ...

problems MAX'ing a range
Hi I've got a set of records (say, for April 2004) that I want to get the MAX value for each day... Worksheet 1: 1/4/2004 2 1/4/2004 4 1/4/2004 1 .. .. .. 2/4/2004 10 2/4/2004 5 .. .. .. 30/4/2004 6 30/4/2004 7 I need Worksheet 2 to end up like this... 1/4/2004 4 2/4/2004 10 .. .. .. 30/4/2004 7 I've tried using =MAX(IF('WkSheet1!A1:A3000=DATE(2004,4,1),Wksheet1!B1:B3000)) but it only seems to retunr the highest in the whole range (umm, 10 in the eaxample above, I guess) Can anyone help me out? I'm not very experienced at ranges so I'm having d...

The stupid budget and transfers problem and brokerage accounts
I found the incredibly stupid fix at http://support.microsoft.com/default.aspx?scid=kb;EN- US;80453 for trying to make transfers show up in budget reports the right way - however I move money around in my brokerage account a lot and there is no way to use that workaround with the investment account because you can't split a transaction in there. Can anyone think of another workaround? My budget just shows $18000 transfers out of budget accoutns so the reports show me as grossly exceeding my budget. This is so stupid, another Microsoft screw-up! Does Quicken deal with this stuff a...

Problem with Public Folder in a dedicated exchange forest
I have a client with an exchange 2003 resource dedicated forest (forestA) and another forest with all the domain accounts (forest B), all the accounts in the exchange server are disabled. But forests are Exchange 2003 Server with SP". There is a trust relationship between the two forests. The forestB trusts in forestA but forestA doesn't trust in forestB. A enabled user from the account forest is associated with a mailbox attached to a disabled user in the resource forest. Since everything is working fine, but I'm havin problems with public folders. When I create a Calend...

OMA and Windows Sharepoint Team Services
Hello, May be it would be usefull for someone. I've found a solution for one of "OMA blank page" problems. I have Exchange 2003 SP1 on Server 2003 and Windows Sharepoint Team Services installed. I can use OWA fine but when I go to the OMA address I get prompted for my login, and then I get a blank page. I've found an event: 1503: --------------------------------------------- An unknown error occurred while processing the current request: Message: File or assembly name System.Web, or one of its dependencies, was not found. Source: mscorlib Stack trace: at System.Ty...

DST Problem?
Hi, I have a problem with my Exchange Server, all meetings are 1hr ahead. This is what I did and I am wondering if there is a way to fix this. I first update a registry entry in Windows 2000 then I upgraded from Exchange 2000 to 2003 applied all patches to Exchange and Service pack 2. I am wondering why did this happen and how could i fix the problem. Thank you, G. Spiro Did you rebase existing appointments in extended DST period? http://exchangepedia.com/blog/2007/02/dst-2007-understanding-what-needs-to-be.html -- Bharat Suneja MVP - Exchange www.zenprise.com NEW blog location: ...

Problem with Outlook XP
Greetings, Recently I did the dreaded 98 upgrade to XP on a legacy machine I have. For outlook, I found that office 2000 was extremely buggy post upgrade so I uninstalled and installed a spare copy of Office XP I had. Now, on this machine, and this machine only, I constantly get the following: Task 'Microsoft Exchange Server' reported error (0x80040111): 'The server is not available. Contact your administrator if this condition persists.' Email still functions as normal however the error is rather annoying. I can't find anything in the KB related. Any input woul...

OWA problem #18
I am using windows 2000 with exchange 2000.My mail server is working fine with outlook express/microsoft outlook. If i am using outlook web access after authentication i will get the the actual screen with inbox but i will not be able to see any new mails.It will be saying loading.... but if i click on new mail it will open the window and i can send the mail and the sender can receive the mail, but if i click inbox it will say loading nothing will come on the screen pls help me... "Suresh M V" <SureshMV@discussions.microsoft.com> wrote: >I am using windows 2000 wit...

Import problem
I have been asked to try and solve a problem that a friend has. (Please try and ignore the workflow - I have suggested other ways of doing it but he won't have it!). He has a spreadsheet containing around 1500 entries. These consist of club members with an exclusive reference number each. My friend is responsible for the overall membership but sends a copy of the file to another person who operates within it month to month. At the end of the period the file is sent back to my friend with new members etc. and my friend then wants to import it into his file (which he has been amending...

Problem opening Word
I can open Word documents in Word but not out of Windows Explorer. Any help? -- JRB See http://word.mvps.org/faqs/apperrors/reregisterword.htm. -- Stefan Blom Microsoft Word MVP "tooltimejack" wrote: > I can open Word documents in Word but not out of Windows Explorer. Any help? > -- > JRB ...

Problems with CString (Conversion from VC6 to VC2005)
Hi all, I have converted a project from VC6.0 to VC2005 (MFC). Now I have a compiling problem. Following error: error C2079: 'myString' uses undefined class 'CString'. CString should now be a template in place of a class. By another project theres is a forward declaration of 'class CString'. I get the following message: error C2371: 'CString' : redefinition; different basic types Thats an indication for the template, but what do I have to do to compile my project again. Regards, Matthias looks like a header file path issue. It seems that when you compi...

Knowledge Consistency problem (5.5)
Has anyone had the following error, and more importantly a fix for it, when running the "Check Now" for the "Check knowledge consistency" "The knowledge consistency check did not correct directory inconsistencies. Be sure the directory service is running, and then try again. If the error recurs, try stopping the directory service and Administrator program and then restarting them. To view details of the error, see the application event log in the Windows NT Event Viewer on the Microsoft Exchange computer on which you checked knowledge consistency. Microsoft Ex...

Problem with #name
Dear All , I am having a problem with the excel. In column 2, I have a set of data which consists of two data 1) "- Cardburry Taste Good (C)" 2) "- Cardburry Taste Bad (M)" 3) "- Cardburry Taste Moderate (K)" When I open the csv files in excel , the data 2) and 3) converted to "#name?" but data 1) is ok. I have made some research if i replace data 2) and 3) with (C) to replace with (M) and (K) ,Everthing is fine .. My question is what is (C) ? Is it a excel formula ? Looking forward for your kindly answer Thanks Ujoon Hi the problem is the minus si...

Replace Entity with GUID Workflow Problem
Hello Community, i created a workflow that sends a Message to customers when a new Case is created. But i discovered that some fields in the email do not contain the right information. The Name of the Customer is replaced with a GUID. Its the same with some other fields. Hope you can help me. Looks like this: Dear {16012172-D811-DC11-A1BF-0003FFB8734F}, We have opened a case "Demo Email 2 - Bildschirm defekt" in response to your request and assigned it to {065C3C16-F009-DC11-9622-0003FFB8734F}. Should you need to follow up on this case, please send e-mail tous or call our mai...

255 Character limit / Comma Delimited Import Problem
Hello, A friend has a comma delimited file and certain fields have more than 255 characters. Is there a Q article someone could point me in the direction of addressing a workaround? Sincerely, Arturo ...

Excel 2000 to Excel 2002 problem
I have put a spreadsheet together using Excel 2000. A friend is trying to use it with Excel 2002 and experiences a problem that I cannot reproduce in Excel 2000. Cell E3 is a persons name. Cell F3 contains the formula '=E3' to auto fill the cell. (If the name is not the correct one it is overwritten) If friend copies the formula in F3 to F4 it copies the formula as an absolute so that it is looking at E3 rather than E4. He is not copying an absolute. He either drags the formula down or copy & pastes. I can't understand what is happening but presume that his version works...

Publisher Mail Merge Stapling Printer Problems
Problem: When printing a mail merged document and collating / stapling it, it puts 2 merged documents together rather than printing / folding 1 and then the next record. In Publisher 2003 / 2002 we were able to use KB article #891904 to put a registry value in to solve the problem. In Publisher 2007 however, there is not a fix posted and the previous fix does not work - at least not one that I know of. I have tried all of the usual searches, GOOGLE, MSFT KB, etc. but the articles that do acknowledge 2007 is on the market do not have a fix for it yet. Even KB891904 does not have ...

publication problems
I am trying to print a program agenda on 11x17 paper...it's showing me (print preview) that it is a 6 page document, however...when it prints, I get 2 blank pages inserted. How do I delete these? Are you trying to print it like a booklet? Two pages per side of paper? -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "Lisa" <Lisa@discussions.microsoft.com> wrote in message news:0C0D0F6F-2DFA-44AA-A8C4-427BA3C0494B@microsoft.com... >I am trying to print a program agenda on 11x17 paper...it's showing me ...

problem with header rule...
i seems to have a problem with only one rule type.. i have a rule that says to permanently delete any mail which contains certain words in the header.. i also have the same basic one for words in senders and recipients names... but on those rules i have no problems with it just checkin the perm. delete only, but on the header rule it turns on the stop processing more rules checkbox automatically if i have the perm. delete on... i dont want the stop one on.. just the perm delete... for now i just moved this rule to last place so it is the last one to process anything ayways, but i wou...

Outlook XP/Exchange 5.5 (scheduling / reminder problems)
First problem: All resources (owned by different users but with each with standard configurations) have Auto Accept and Refuse if conflict options actived in calendar. Some resources work OK, some will not Auto Accept and some Auto Accept even if there is a conflict. Any ideas on how to fix this? Second problem: Although all calendar reminder options are activated, some people do not receive them. How about ideas on this one? Thank you for all and any suggestions you may have! Send reponse to donna.brich@brp.com please. ...

E-Mail Printing Problem
I posted this problem 6 or 8 months ago and have not yet seen a solution. The problem is on certain emails (Schwab Confirms as an Example) about 1" of the right side of the email is cropped. I documented and reported the problem to MSFT and someone from MSFT replied that they were aware of the issue and were working on it. That was many many months ago. The problem is/was not printer dependent or operating system dependant - just Internet Explorer and/or Windows Live Mail. It was apparent at that time that other people were experiencing the same problem. Is anyone aware...

Active Cell problem
I have a VBA function that is located in several Cells [=myFunction(dataRange as Range)]. For the function to work during Excel Recalculation process, I need to now the address that Excel is recalculating. Say the formula is located in the 12 Cells, A1:B6. As Excel works through the recalculation, my function needs the know the cell (A1:B6) Excel is recalculating. I tried Set HomeCell = Range(ActiveCell.Address) With this, I only get the cell where the cursor is located at the time Excel starts the recalculation. Thanks for the help And you're calling the fun...

Problem MFC size dialog
Hello! I have a problem in MFC whit Visual C++ 6.0 I want that the dialog size will be 1024*764 and i haven't do it. I need help Thanks -- u17737 ------------------------------------------------------------------------ Posted via http://www.codecomments.com ------------------------------------------------------------------------ u17737 wrote: > Hello! > I have a problem in MFC whit Visual C++ 6.0 > I want that the dialog size will be 1024*764 and i haven't do it. > I need help > Thanks That is not a very smart thing to want. What will happen if the program is r...

Problem using rules wizard script
Hi there I'm have a problem using rules wizard script with outlook 2003 on a windows xp. I have got the follwoing code from the microsoft site: Sub CustomMailMessageRule(Item As Outlook.MailItem) MsgBox "Mail message arrived:" & Item.Subject End Sub In Outlook I activated the editor with Alt F11 and add this text in Project1 - Microsoft Outlook - ThisOutlookSession After this I created a rule checking the subject and excute the script CustomMailMessageRule. I restarted Outook and even the PC but the script doesn't come up. What did I miss ? Thanks in advance f...

Outlook 2002 Rules Wizard Problem
When I try to open the rules wizard I get the following message: The command is not available. Please see the documentation about how to use this extentsion. I looked within Outlook's Help and this is nothing there about it. How do I install the Rules Wizard? Oh and I looked on the Office XP CD and did not find it listed within the Outlook files. ...