473,405 Members | 2,310 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,405 software developers and data experts.

Problem with Visual Studio 2008 and release configuration (struct and vector)

Hi everyboby,

I have some problem using the release configuration of Visual Studio and the following code. Is there anybody who can tell me how to use struct with inside a vector?

Thank you

Expand|Select|Wrap|Line Numbers
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <assert.h>
  4. #include <time.h>
  5. #include <iostream>
  6. #include <fstream>
  7. #include <math.h>
  8. #include <string.h>
  9. #include <errno.h>
  10. #include <string>
  11. #include <sstream>
  12. #include <errno.h>
  13. #include <vector>
  14. #include <algorithm>
  15. #include <set>
  16.  
  17. using namespace std;
  18.  
  19. typedef struct{
  20.     int progressivo;
  21.     int colonna_temporale_IN[1500];
  22.     int colonna_temporale_OUT[1500];
  23. }risorsa_localita;
  24.  
  25. typedef struct{
  26.     int progressivo;
  27.     vector <risorsa_localita > risorse_localita;
  28. }struttura_risorse_localita;
  29.  
  30. struttura_risorse_localita *vettore_risorse_localita;
  31.  
  32. int main() 
  33.     int i,j,k;
  34.  
  35.     vettore_risorse_localita=(struttura_risorse_localita *)calloc(1000,sizeof(struttura_risorse_localita));
  36.  
  37.     for(i=0;i<1000;i++){
  38.  
  39.         vettore_risorse_localita[i].progressivo=i;
  40.  
  41.         for(j=0;j<5;j++){
  42.  
  43.                 risorsa_localita risorsa_appoggio;
  44.  
  45.                 for(k=0;k<1500;k++){risorsa_appoggio.colonna_temporale_IN[k]=0;}
  46.                 for(k=0;k<1500;k++){risorsa_appoggio.colonna_temporale_OUT[k]=0;}
  47.  
  48.                 vettore_risorse_localita[i].risorse_localita.push_back(risorsa_appoggio);    
  49.         }
  50.  
  51.  
  52.         cout << "PREMI INVIO\n";
  53.         cin.get();
  54.  
  55.         return 1;
  56.     }
  57. }
Feb 2 '10 #1
2 2558
Banfa
9,065 Expert Mod 8TB
You haven't said what the problem is which makes it hard to help.

However you absolutely should no use malloc/callo/free in C++ especially with classes as the constructors do not get called. Allocate your memory with new and release it with delete.
Feb 3 '10 #2
weaknessforcats
9,208 Expert Mod 8TB
Also, keep in mind that a C++ class is implemented as a struct. So if you can use a vector with a class then you already know how to use it with a struct.

A C++ struct is identical to a C++ class that has all members public.
Feb 3 '10 #3

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

Similar topics

7
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using...
19
by: Alf P. Steinbach | last post by:
// As usual the error message directs one to the report the bug. // // And as usual there is absolutely no way to do so without paying for // the privilege... // // Or using three or four hours...
15
by: Ken Allen | last post by:
I have been developing a suite of assemblies over the past couple of weeks, and this afternoon somethign started misbehaving. If I do not run the IDE and compiler the code from the command line,...
1
by: marco_segurini | last post by:
Hi, At the moment I am using Visual Studio 2005 beta 1. The following program does not compile using the debug configuration setting the "Disable Language Extensions" flag to "Yes(/Za)" while...
13
by: kamaraj80 | last post by:
Hi I am using the std:: map as following. typedef struct _SeatRowCols { long nSeatRow; unsigned char ucSeatLetter; }SeatRowCols; typedef struct _NetData
9
by: Prasad | last post by:
HI, I am a beginner in VC++.. I am trying to write a Win32 console application in visual studio.. I am using following header files.. #include <STRING> using namespace std; #include...
4
by: kurt.kurtsmith | last post by:
I am trying to import a tlb from a COM server(exe) I wrote with the following statement: #import "C:\\em2\\EM\\src\\core\\UMOSEFax\\Debug\\UMOSEFax.tlb" no_namespace auto_search the tlh and...
3
by: =?Utf-8?B?QU0=?= | last post by:
Is there a way to work on visual studio 2003 projects using visual studio 2005 without converting, maintaining original code? Thanks AM
5
by: =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?= | last post by:
Does Visual Studio 2005 and Visual Studio 2008 work well together on a Vista computer? I am having some issues with Ajax development. Neither VS2005 nor VS 2008 work well since I installed Visual...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I cut and paste the following code from msdn help page which it just introduces view and multiview server controls. Here is what I do: in vs studio 2005, File --New Web Site, it...
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?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
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 project—planning, coding, testing,...

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.