Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

VB can not call the methods that take c++ classes as parameters or return values, such as std::string. And VB will have to call the methods by their mangled names as generated by the c++ compiler.

Intrade commented: Succint information to answer the question. Much obliged! +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use cout

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you wrote the program as MS-Windows GUI, such as it uses WinMain() instead of main(), then that link error tells me that you created the wrong kind of project. You should have started with a Win32 Project, not a Win32 Console Application (assuming your compiler is VC++ 2010).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You will probably have to ask whoever you got that library from.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Each node in the linked list will contain the information for one student. First create a structure with all the information you want about a student then add a next pointer for the linked list.

If you need more information then you will have to be a lot more specific acout what you want and what you don't understand about your assignment.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yup. That's all there is to it. Read the instructions carefully. I assume you will need two of those arrays.
>>Each vector will contain exactly 8 floating point values

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To add a node at the end of the linked list the function will have to start at the head and iterate until it finds the last node -- which will be the node where the next pointer is NULL (or 0). Once that node is found just set the next pointer to the new node and make the new node's next pointer = NULL.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

A c++ vector is just the c++ implementation of a normal array. So when the instructions tell you there are exactly 8 floating point values in the vector, that means declare an array like this: float values[8]; If you are confused about how to use arrays then read one of these tutorials

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The code I posted earlier will get you the difference in seconds. All you have to do is make the calculations that I posted here.

I'm not going to do all the homewoprk for you. You have to learn how to use your head for something other than a hat rack. This problem is nothing more than 4th grade math. How many years are there in X number of seconds. Any 10 year old should be able to solve that problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Call time() to get the current data/time. This will give you the current time in seconds snce 1970. There is no function in time.h that returns the number of seconds since year 0 because it would be too big a number.

Now, once you have the year, month and day of birth, populate a struct tm with it and call mktime() to covert to seconds sine 1970.

Example:

#include <stdio.h>
#include <time.h>
#include <string.h>

int main()
{
    struct tm tm;
    int month = 1;
    int year = 2010;
    int day = 1;
    time_t today, dob;
    memset(&tm,0,sizeof(struct tm));
    tm.tm_year = year - 1900; // Number of years since 1900
    tm.tm_mon = month-1; // months are 0 based, so that 0 = Jan, 1 = Feb, etc
    tm.tm_mday = day;
    dob = mktime(&tm);

    today = time(0);
    double diff = difftime(today,dob);


    printf("dob = %u\n", dob);
    printf("diff = %lf\n", diff);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I already told you.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

simple --

const int seconds_per_minute = 60;
const int seconds_per_hour = seconds_per_minute * 60;
const int seconds_per_day = seconds_per_hour * 24;
const int seconds_per_year = seconds_per_day * 365;


int seconds = 123444445;
int years = seconds % seconds_per_year;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Create a new project then copy (with Windows Explorer) the *.cpp and *.h files from the other two files into it. Then in the Solution Explorer window of VC++ 2010 right click "Source Files" and from the popup menu select Add --> Existing Item.

Or, if I misunderstood what you wanted, you can have both projects in the same solution. In one of the projects select File --> Add --> Existing Project

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

We can't help you if you don't post the code. And tell us the exact error message -- what unresolved symnbol? You will get that if you put a method in a class but not the method's implementation code.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

find_first_of() doesn't work like that. There are several ways to do it, here is just one of them.

string colors[4] = {"CYAN", "MAGENTA", "YELLOW", "BLUE"};

<snip>
bool found = false;
for(int i = 0; i < 4; i++)
{
   if( colorData == colors[i] )
   {
      found = true;
      break;
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Heres the build log...
For what?

Disable precompiled headers for that project. Or add #include "stdafx.h" at the top of each *.cpp file in the project.

And make sure its in a *.cpp file, not *.c. C programs can not use precompiled headers or STL containers such as vector

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>@AD: What forum are we in -- std::sort ??

Oops! My bad, I have a habit of confusing c and c++ forums. I had one of those senior moments of memory lapse :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Its not copy-paste-able in VC++2010,

Funny -- I didn't have any trouble doing that. Just copy/paste into an existing console project.

vectors are c++ implementation of arays, not stacks. There is another class called stack. You might want to read up on STL containers.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Its all about something called the "comma operator" Here and Here are two more links

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

How to erase the screen is operating system dependent. The simplest way to do it is system("cls"); or for *nix syte("clear"); But both those are not recommended because they can intoduce your program to hackets.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Those functions can be used in either console or GUI programs. There are a lot of win32 api functions that can be called from console programs.

FindFirstFile() and FindNextFile() are very similar in concept to opendir() and readdir() for *nix. All you have to do is include <windows.h> then use google to get the full descriptions of those functions from MSDN. I have even posted code examples using those functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Just because entries has room for 20 items don't assume that all items were used. What happens to that sort algorithm is only 2 items were actually used?

You need another counter to keep track of the number of items actually used in that array. Then that sort() function will most likely work wither its sorted in ascending or descending order. Of course you will have to use that same counter in the other functions, such as print()

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you are concerned about security in your programs then don't use pipes to execute M$ stock command. Most, if not all, those commands have win32 api equivalent functions. For dir you can call FindFirstFile() and FindNextFile() to do the same thing.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Link

>>plz let me find a simple code
Bubble sort algorithm is as simple as it gets when you have to write your own algorithm. Otherwise you can just use std::sort() that's found in <algorithm> header file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>orly? 0.0

Huh??? The ls command you have in your link is probably from one of the gnu libraries, not standard MS-Windows command. You will not be able to run that program on other computers with MS-Windows unless you also install that ls.exe program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you can not use sizeof to get the number of bytes allocated to an array. All sizeof(any pointer here) does is give you the size of a pointer -- on 32-bit compilers it will be 4.

There are two solutions I can think of:
1. Use vector instead of array, such as std::vector<double> ay; You can call vector's size() method to get the number of doubles it contains.

2. Pass the array size as another parameter to the functinon.

n0de commented: Thanks ;) +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

ls doesn't work on Windows 7

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\Ancient Dragon>ls
'ls' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Ancient Dragon>

If you want the filenames then use /b option

C:\Users\Ancient Dragon>dir /b
Contacts
Desktop
Documents
Downloads
Favorites
Links
Music
Pictures
Saved Games
Searches
Videos
workspace

C:\Users\Ancient Dragon>

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

VC++ 2010 Express errors

1>ResourceManager.obj : error LNK2019: unresolved external symbol "public: void __thiscall bge::Resource<class bge::IFont>::SetFilename(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?SetFilename@?$Resource@VIFont@bge@@@bge@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: bool __thiscall bge::ResourceManager::AddFont(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool)" (?AddFont@ResourceManager@bge@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0_N@Z)
1>ResourceManager.obj : error LNK2019: unresolved external symbol "public: __thiscall bge::Resource<class bge::IFont>::~Resource<class bge::IFont>(void)" (??1?$Resource@VIFont@bge@@@bge@@QAE@XZ) referenced in function "public: bool __thiscall bge::ResourceManager::AddFont(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool)" (?AddFont@ResourceManager@bge@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0_N@Z)
1>ResourceManager.obj : error LNK2019: unresolved external symbol "public: __thiscall bge::Resource<class bge::IFont>::Resource<class bge::IFont>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$Resource@VIFont@bge@@@bge@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: bool __thiscall bge::ResourceManager::AddFont(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool)" (?AddFont@ResourceManager@bge@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0_N@Z)
1>ResourceManager.obj : error LNK2019: unresolved external symbol "public: void __thiscall bge::Resource<class bge::IImage>::SetFilename(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?SetFilename@?$Resource@VIImage@bge@@@bge@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: bool __thiscall bge::ResourceManager::AddImage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool)" (?AddImage@ResourceManager@bge@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0_N@Z)
1>ResourceManager.obj : error LNK2019: unresolved external symbol "public: __thiscall bge::Resource<class bge::IImage>::Resource<class bge::IImage>(void)" (??0?$Resource@VIImage@bge@@@bge@@QAE@XZ) referenced in function "public: bool __thiscall bge::ResourceManager::AddImage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool)" (?AddImage@ResourceManager@bge@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0_N@Z)
1>ResourceManager.obj : error LNK2019: unresolved external symbol "public: __thiscall bge::Resource<class bge::IImage>::~Resource<class bge::IImage>(void)" (??1?$Resource@VIImage@bge@@@bge@@QAE@XZ) referenced in function "public: bool __thiscall bge::ResourceManager::AddImage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool)" (?AddImage@ResourceManager@bge@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0_N@Z)
1>ResourceManager.obj : error LNK2019: unresolved external symbol "public: __thiscall bge::Resource<class bge::IImage>::Resource<class bge::IImage>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$Resource@VIImage@bge@@@bge@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: bool …

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>but I can change it, it dosent matter too much to me.


Well it will matter to the operating system :)

>>How would I allow the function to return an array of chars? char* getStdOut(char *cmd) Now you will want to make that string getStdout(char* cmd) because a function can not return a character array that is declared on the stack as ps is declared in that function. You could change ps to a pointer and use malloc() to allocate memory for it, but using std::string in a c++ program would be a better and easier solution.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

time.h has a function named difftime() that returns the difference between two time_t variables in seconds.

Step 1: get birth date.convert it to struct tm the call mktime() which will return the time_t variable.

Step 2: call time() to get current data/time in time_t

Step 3. Call difftime() to get the difference in seconds

Step 4. Convert the result of Step 3 into years, months, days, seconds. To do that is just simply a matter of subtraction.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

See your CONTROL PANEL link at the top of the page.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You are using VC++ 2010 on MS-Windows but attempting to run a *nix ls command???? On MS-Windows the equivalent of ls is dir.

>>strcat(ps,psBuffer);
You will have to initialize ps to 0 before that line. Do it when it is declared, char ps[1024] = {0}; I think it would be better to use a linked list because the results of dir can be very very huge. In c++ just use vector<string> filelist;

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't know the answeres to those questions. I'd need the entire program so that I can compile/check it myself.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It is initializing each array element with random numbers between the two values you see.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>'Clean All Targets' (which I think is a complete rebuild?).

No it doesn't mean that. Clean means to just delete all the files that are generated by the compiler, such as *.obj, *.o, *.lib, *.dll, *.pch, etc.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>extension (.bin) means that the file is in binary mode

No it doesn't, as the code you posted illustrates. The file extension has nothing to do with whether the file is in binary or text mode. Your own program proved it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>would prefer it to be standard C++ not visual studio C++
VC++ is a compiler, not a language.

#include <windows.h>

int main()
{
    HWND hWnd = GetConsoleWindow();
    ShowWindow(hWnd, SW_MINIMIZE);
    // rest of program goes here
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Pass by reference allows one function to change the value of a variable that is declared in another function. For example, put the following into your compiler, compile and run it. Then you will see how pass by reference works.

More in-depts explaination is here.

#include <iostream>

void foo(int& x)
{
   x = 10;
}

int main()
{
   int color = 0;
   foo(color);
   std::cout << color << '\n';
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you don't specify otherwise the default cout will display only 6 significant digits both before and after the decimal point but without leading or tailing 0s.

If you add fixed cout << "String: " << fixed << fTEST << " length: " << sL.length() << "\n"; it will display more digits.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Code::Blocks w/MinGW compiler. For some reason the length is not the same as with VC++ 2010 Express.

In which column data is?
7
String: 688609.5 length: 9
String: 545077.56 length: 9
String: 492410.06 length: 9
String: 479745.75 length: 9
String: 397472.59 length: 9
String: 322399.22 length: 9
String: 313920.53 length: 9
String: 310676.25 length: 9
String: 301033.41 length: 9
String: 253613.02 length: 9
String: 249180.86 length: 9
String: 212169.12 length: 9
String: 194152.77 length: 9
String: 179574.28 length: 9
String: 176200.3 length: 9
String: 168904.89 length: 9
String: 163588.73 length: 9
String: 158025.33 length: 9
String: 154117.23 length: 9
String: 134688.05 length: 9
String: 130347.8 length: 9
String: 120936.63 length: 9
String: 120706.15 length: 9
String: 103261.97 length: 9
String: 100171.06 length: 9
String: 98498.453 length: 8
String: 91046.797 length: 8
String: 87599.477 length: 8
String: 81331.117 length: 8
String: 78216.523 length: 8
String: 77100.492 length: 8
String: 74609.227 length: 8
String: 71967.641 length: 8
String: 71522.812 length: 8
String: 70197.523 length: 8
String: 70009.492 length: 8
String: 69391.477 length: 8
String: 67461.5 length: 8
String: 65430.859 length: 8
String: 63470.82 length: 8
String: 58885.488 length: 8
String: 57822.172 length: 8
String: 57336.828 length: 8
String: 55385.309 length: 8
String: 50895.75 length: 8

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I compiled and ran with VC++ 2010 Express. Here is the output

In which column data is?
7
String: 688609.5 length: 9
String: 545077.56 length: 9
String: 492410.06 length: 9
String: 479745.75 length: 9
String: 397472.59 length: 9
String: 322399.22 length: 9
String: 313920.53 length: 9
String: 310676.25 length: 9
String: 301033.41 length: 9
String: 253613.02 length: 9
String: 249180.86 length: 9
String: 212169.13 length: 9
String: 194152.77 length: 9
String: 179574.28 length: 9
String: 176200.3 length: 9
String: 168904.89 length: 9
String: 163588.73 length: 9
String: 158025.33 length: 9
String: 154117.23 length: 9
String: 134688.05 length: 9
String: 130347.8 length: 9
String: 120936.63 length: 9
String: 120706.15 length: 9
String: 103261.97 length: 9
String: 100171.06 length: 9
String: 98498.453 length: 8
String: 91046.797 length: 8
String: 87599.477 length: 8
String: 81331.117 length: 8
String: 78216.523 length: 8
String: 77100.492 length: 8
String: 74609.227 length: 8
String: 71967.641 length: 8
String: 71522.813 length: 8
String: 70197.523 length: 8
String: 70009.492 length: 8
String: 69391.477 length: 8
String: 67461.5 length: 8
String: 65430.859 length: 8
String: 63470.82 length: 8
String: 58885.488 length: 8
String: 57822.172 length: 8
String: 57336.828 length: 8
String: 55385.309 length: 8
String: 50895.75 length: 8
String: 50323.75 length: 8

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

the easiest way is that you save the file with the extension of (.bin) instead of (.txt)

The file extension has nothing to do about file contents. Changing the file extension from .txt to .bin will do nothing (other than renaming the file)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are you blind or just plain stupid?

Unimportant commented: lol 2007 +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

which column is the data in that you want to use?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

sprintf_s is not part of the C standard library -- its Microsoft specific and was introduced in Microsoft compilers just within the past 5 or so years. If you want to use it with that ancien compiler then you will have to implement it yourself. You can't put a 2010 engine in a 1908 Model T.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

call win32 api ShellExecute() or CreateProcess() instead of system() to execute another program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Look, if you remove setprecision from that cout, you get only one digit after floating point

cout does not display trailing 0s therefore 609.50 will be displayed as 609.5.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you try ShowWindow(SW_MINIMIZE)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well you had better find out because it will be impossible to parse that file until you know that.

Looks like LibreOffice is only in beta -- it could contain bugs. Get and use OpenOffice instead.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Why are the first 7 lines different than from the rest of the lines in the file?