![]() |
|
|
|||||||
| Home | Forums | Register | Rules & FAQ | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
Other UNIX.COM Threads You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to transpose data elements in awk | ahjiefreak | Shell Programming and Scripting | 2 | 05-13-2008 01:44 AM |
| just want certail elements | frenchface | Shell Programming and Scripting | 1 | 05-10-2008 06:38 PM |
| Reomve elements from a path name | kgeasler | Shell Programming and Scripting | 3 | 03-26-2008 10:48 AM |
| Read elements of a xml file?????? | ahmedwaseem2000 | Shell Programming and Scripting | 6 | 01-23-2008 11:50 PM |
| How to list mirrored elements? (pv, vg, lv) | cactux | AIX | 4 | 11-29-2006 06:21 AM |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Map - printing all elements - why?
Hi All
I have written a map program. The program is simple I have the input file input.dat which has the following Code:
BLACK 000180 TECH1 BLUE 000340 TECH2 a[BLACK]=first row ie Black 000180 and TECH1 a[BLUE ]=second row i.e BLUE 000340 and TECH2 Code:
struct CHAR
{
char chr[5];
char val[5];
char code[6];
};
multimap<string , CHAR> names;
int main()
{
char temp1[1024];
struct CHAR ch;
memset(temp1,0x00,1024);
FILE *IF1;
string S;
char *ptr;
IF1=fopen("input.dat","r");
while (fgets(temp1,1024,IF1) != NULL)
{
ptr=temp1;
for(;*(ptr) != '\n';ptr=ptr+41)
{
s trncpy(ch.chr,ptr,5);
strncpy(ch.code,ptr+5,6);
strncpy(ch.code+11,5);
S=ch.chr_name;
names.insert(multimap<string,CHAR>::value_type(S,ch));
}
}
multimap<string, CHAR>::iterator p;
for(p=names.begin();p!=names.end();p++)
cout<<p->second.chr<<endl;
}
the whole file BLACK 000180 TECH1 BLUE 000340 TECH2 I don;t understand when i want to print second.chr alone why it prints all? Can any one help? Regards Dhanamurthy Last edited by Yogesh Sawant : 04-14-2008 at 10:22 AM. Reason: added code tags |
|||
| Google UNIX.COM |
| Forum Sponsor | ||
|
|