Thread: manipulating struct members

  1. #1
    Registered User
    Join Date
    Jan 2014
    Posts
    1

    manipulating struct members

    So am doing a practise problem from jumping into c++. Let me try to explain a problem I have.I have built array of structures that contains int(num of days) and string(Name).So basicy user should enter name of a friend and days they last talked,and then make a list sorted by the names of the friends of by how recently it was since they talked to each friend.So my idea is to take num of days,and sort them, but then I dont know how to connect that again with Names so I can print it out. am not looking for a homework solution, just some guidance. thanks

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You can sort your array so it is sorted by number of days. You can use std::sort and give it a custom function that specifies the search criteria.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    if you have a modern C++ compiler, you can even do it inline with a lambda.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 12-17-2013, 02:19 PM
  2. Help Manipulating String of Struct Array in Functions
    By seannabeast in forum C Programming
    Replies: 5
    Last Post: 11-16-2011, 08:34 PM
  3. accesing struct members
    By kennny2004 in forum C++ Programming
    Replies: 2
    Last Post: 05-23-2006, 11:31 PM
  4. Pointer to struct members
    By kybert in forum C Programming
    Replies: 7
    Last Post: 07-01-2003, 08:27 AM
  5. comparing struct members
    By breed in forum C Programming
    Replies: 4
    Last Post: 11-22-2001, 12:27 PM

Tags for this Thread