I do not need anything too complex, I just need to be able to graph and plot some simple 2D graphs. There is a lot of scattered info all over the internet and at work I dont want to download one of these free softwares and have it blow up my computer.

Any Advice? Free and not free graphing software??
Thanks!

I have a basic questions. I have written a program in C++ and I would like to create a GUI for it.

I have a book Microsoft Visual Basic C++.net that has a great tutorial, but its in clr/c++. Is it possible to program a GUI in this language in use it on a c++ code.

I just want to know before I start and then find out it is not possible

Thank You@

for anyone that may ever need help. This find the last line of a csv and parses it

[CODE]#define _LLBUFFSIZE 2048
string lastLine;
lastLine.clear(); // regardless, zero out our return string
char buff[_LLBUFFSIZE]; // our temporary input buffer
data_filet.seekg (0, ios::end); // go to end of file
int length = data_filet.tellg(); // find out how large it is
data_filet.seekg(length-min(length,_LLBUFFSIZE),ios::beg); // seek back from end a short ways
// read in each line of the file until we're done
buff[0]=0;
do{if (!isspace(buff[0]) && buff[0] != 0)
lastLine = buff;
}

while (data_filet.getline(buff, _LL_BUFFSIZE_));
cout <<"last ="<< lastLine << endl;//Last line of t stored as 
cout << typeid(lastLine).name() << endl; 

char *a=new char[lastLine.size()+1];
a[lastLine.size()]=0;
memcpy(a,lastLine.c_str(),lastLine.size());
char * pch;
printf ("Splitting string \"%a\" into tokens:\n",a);
cout<<"Problem"<<endl;
pch = strtok (a,", ");

while (pch != NULL)
{
    printf ("%s\n",pch);
    pch = strtok (NULL, " ,-");
}[/CODE]

Thanks L7

[QUOTE=WaltP;1502102]Probably because you tried to add code you don't understand and expect it to work without modification. It's obvious from the code you posted [B]L7Sqr[/B]'s code is far beyond your level.[/QUOTE]

It is obvious to me that common decency is far beyond your level.

debasisdas commented: should know how to behave in a public place, dont show attitude here. -2

[QUOTE=WaltP;1502080]You need to parse the line. Find each (,) and
1) Convert the value to float and store it.
2) Search for a comma
3) If found, skip over it and go back to 1[/QUOTE]

I dont know how to do this. Strtok? and a for loop?

[QUOTE=L7Sqr;1502074]The conversion can be tricky (does your csv allow quoted commas?) but you could just translate all ',' to ' ' and parse using a stringstream. For example:[code]#include <iostream>

include <string>
include <vector>
include <sstream>

int main () {
std::string s = "123.45,213.76,234.16";
std::size_t pos = 0;
std::vector< double > vd;
double d = 0.0;

// convert ',' to ' '
while (pos < s.size ())
    if ((pos = s.find_first_of (',',pos)) != std::string::npos)
        s[pos] = ' ';

std::stringstream ss(s);
while (ss >> d)
    vd.push_back (d);

for (int i = 0; i < vd.size (); ++i)
    std::cout << "vd[" << i << "] = " << vd[i] << std::endl;
return 0;

}[/code][/QUOTE]

Thank You, this code works for me but when I try and sub the lastLine I get from my code in place of your s it does not work? Why is this?

[CODE]#define _LLBUFFSIZE 2048
string lastLine;
lastLine.clear(); // regardless, zero out our return string
char buff[_LLBUFFSIZE]; // our temporary input buffer
data_filet.seekg (0, ios::end); // go to end of file
int length = data_filet.tellg(); // find out how large it is
data_filet.seekg(length-min(length,_LLBUFFSIZE),ios::beg); // seek back from end a short ways
// read in each line of the file until we're done
buff[0]=0;
do{if (!isspace(buff[0]) && buff[0] != 0)
lastLine = buff;
} while (data_filet.getline(buff, _LLBUFFSIZE));
cout <<"last ="<< lastLine << endl;//Last line of t stored as
cout << typeid(lastLine).name() << endl; [/CODE]

I use this code to read the last line of a csv file and the value of lastLine is
"29.27,83.37,39,43" etc. The number of values changes everything. I need to find a way to store this string as an array of those numbers. Where say t[0]=29.27 and t[1]=83.83 and so on. Thanks!

nevermind

I just added a 0 onto the front of the date I read in and then I will use assign

I am using getline to read a CSV file.

The line it reads looks something like

"1/24/2010 6:19 1/24/2010 6:59 Merrill - Valley Farms yhy 69 Vegetation 55"

The getline works but, I need to be able to calculate time days between a date the user inputs and the date here. AKA the first few characters in the line. I have tried to use assign and store them to arrays, which works great expect for sometimes the month is 1 or it could be 10, 11 or 12 and then assign does not work correctly.

I have also tried strchr which does not work. My code looks like this, I think the way is to use pointers, I have looked all over and I cannot find a way to do it, especially be able to find the second delimiter.

[CODE]while (! lineseg.eof() && getline(lineseg,data).good() )
{
if( (found=data.find (term[2],0)) !=string::npos && (found=data.find (voltage,0)) !=string::npos)
{

    }}[/CODE]

I get those values from reading in a CSV

Hmmm alright, I was hoping there was a way to just remove them and in turn change the size as well. I will have to do some thinking. Thank you

WaltP,

I would like it to look like the latter.

[CODE]t[]={1,2,3,6,7}[/CODE]

I have thought about vectors but I would rather find a way to do this with arrays. Copying is a thought, I will look into it

I have read many different threads about how it is not possible to delete values from an array, but I need to find some way to do this.

I am making a program that involves a bottom up approach algorithm where it pairs off data segments, finds the best segments to merge and then merges them. I have it telling me which segments it should merge but then to merge them I need to be able to go in a remove certain values from that array. I can find them by the index or actual value I suppose.

ex

[CODE]

t[]={1,2,3,4,5,6,7}

[/CODE]

and I need to remove 4 and 5 and then send the array back through all my functions.

Thanks!@

[CODE]for (int i=0, a=0;i<n;i++, a=a+2)
{
m[i]=((lnnum[a]-lnnum[a+1])/(lnt[a]-lnt[a+1]));
}[/CODE]

NEVERMIND!

I do not know if I should use a 2D or just two seperate arrays to make this easier.

I have two arrays. One is just an array like {1,2,3,4...n} and the other has values that correspond to those and make pairs.

I want to create an array that stores the slopes of the points.
m[n/2] would have m[0] the slope from the first two points and m[1] has slopes from point 2-3 and so on. Basically making segments and taking the slopes of those segments.

I have tried a few things
[CODE]for (int i=0;i<n;i++)
for (int j=0;j<n;j++)
m[i]=((lnnum[j]-lnnum[j+1])/(lnt[j]-lnt[j+1]));
j=j+2;[/CODE]

This one of the closest. I get the correct values with every other value in m

[CODE]for (int i=0;i<n;i++)
{
m[i]=((lnnum[i]-lnnum[i+1])/(lnt[i]-lnt[i+1]));
i=i+1;
}[/CODE]

I forgot to include a few other parts of the code in order to simplify. I just want to know if it is possible to pass that value of n to the function as an array size?

[CODE]
int main()
{

     double t[]={15.70, 29.39, 41.14, 56.47, 75.61, 98.83 ,112.42, 125.61, 129.39, 133.45,138.94, 141.41, 143.67, 144.63, 144.95, 145.16, 146.25, 146.70, 147.26 , 148.15, 152.40};

int n = sizeof (t)/sizeof (t[0]);
     FindLN(t, n);
return 0;

}

void FindLN(double t[], int n)
{
int index;
double lnt[n];

for (index=0; index<n; index++)
{
    lnt[index]=log(t[index]);
    lnnum[index]=log(num[index]);
}

}
[/CODE]

I get a few errors but Im quite certain they are all related

Errors

expected constant expression at double lnt[n];
cannot allocate array size 0 and lnt unknown size at this line

HELP Please

[CODE]Scan:
while (! data_file.eof() && getline(data_file,line).good() )
{
if( (found=line.find (term[adv],0)) !=string::npos && (found=line.find (voltage,0)) !=string::npos)
{
number++;
cout<<line<<'\n';
out_file<<line<<endl;
}}

    adv=adv+1;
    data_file.close();
    data_file.seekg(0,std::ios::beg); //reset read pos to beginning
    data_file.clear(); //clear eofbit
    if (adv<subtranslines)
    {

    out_file<<term[adv]<<"outages"<<endl;
    goto Scan;
    }[/CODE]

AHHHH! Whats wrong here! No errors but it will not go back into that first while loop again! I tried resetting the values

well If i do not re open the file, it will not re enter the while loop again. Hence my previous question on how to clear that value.

As far as goto, I dont know what else to use

[CODE]Scan:
ifstream data_file("DailyReport(2).csv");
if(data_file.bad()){
printf("Could not open File!\n");
exit (8);}
else{
printf("File opened successfully\n");}

    while (! data_file.eof() && getline(data_file,line).good() )
    {
    if( (found=line.find (term[adv],0)) !=string::npos && (found=line.find (voltage,0)) !=string::npos)
    {
    number++;
    cout<<line<<'\n';
    out_file<<line<<endl;
    }}
    adv=adv+1;
    if (adv<subtranslines)
    {
    goto Scan;
    }[/CODE]

I figure it all out, but is there a better way to do this??

I am very close

[CODE]while (! data_file.eof() && getline(data_file,line).good() )[/CODE]

Where does this line store the value so I can clear it????

im pretty sure my looping is incorrect

That wont do what I want though? I want to search the csv file for the term "Jordan", write them to another file, count how many times it exists and then search for the next term "Smith" and keep going. I would need a loop for that. Concatenating wont do what I want I dont think

ah I am at work and that site is blocked! Can you give me another example please?

and I removed those quotes. It wasnt working so I was just trying some things

well I am going to add more to that string

[CODE]int number=0, subtranslines=50;
string term[]={"Jordan"};
//string term="Jordan";
string voltage= "69";
string line;
size_t found;

while (! data_file.eof() && getline(data_file,line).good() )
{
    //cout<<line<<'\n';
    for (int i=0; i <=subtranslines; i++){
    if( (found=line.find ("term[i]",0)) !=string::npos && (found=line.find (voltage,0)) !=string::npos)
    {
    number++;
    cout<<line<<'\n';
    out_file<<line<<endl;
    }}}
//To find the number of outages and subtract the header
    cout<<"number = "<<number<<'\n';

[/CODE]

The code works when I do not try to pass term[i] and just use term. What I am trying to do is read in a file, search for a word, if the row contains that word write it to a file and keep searching until it does not find it and then search for the next word, find, write it and so on.

For some reason it will not work when I try and use an array.

Another questions...
On the line
[CODE]if( (found=line.find ("term[i]",0)) !=string::npos && (found=line.find (voltage,0)) !=string::npos)
[/CODE]

What does the ,0 do after the two terms??

Thank YOU!

Ok that explains some things, I suppose it will be a better idea for me to code it in c++. It will be much easier to search for things and get help than using the other hybridish language. Thank!

I am just having trouble with the beginning stages here. I am just very confused on different syntax terms.

I have a book here "Microsoft Visual C++.net" with all the installation and whatnot with it. It doesnt use the normal cin and cout but used Console::WriteLine and what not.

Is this still considered c++ or it another form or type? Does it matter at the beginning when I open a file if I go to console application or something else? It seems to be very closely realted but different in some other ways, like using the find function does not seem to work with some examples I have found online?

I know I am missing something very basic but the book does not really explain.

Thanks!