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

After all, a hard drive doesn't see chars, or ints, or doubles - it just sees bits. So it really doesn't matter what we output the data as in C++. Once it gets to the hard drive, it becomes bits, and then any program can interpret the data in the file any way it wants.

True, but that doesn't mean the program will interpret the data correctly. Example: move a file written in text mode on MS-Windows to *nix, then use a *nix text editor to read it. Or do the opposite -- move a text file writting on *nix to MS-Windows and use Notepad.exe to read it. In both cases the editor will mis-interpret the line feeds. In some cases the text editor may be smart enough to translate the file correctly, but most simple text editors such as Notepad.exe can not do that.

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

what are the 4 errors ? and repost code if its different than what you posted before.

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

You can easily test your question yourself. Write a small program to find out how the >> operator behaves. I could easily tell you, but testing it out yourself is a much better teacher.

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

The difference also depends on the operating system -- on *nix there is no difference between text and binary written files because *nix compilers make no translation of the '\n' character in either mode. That is, the file itself will contain the same information whether writting with a stream opened in text or binary mode.

That is not true for files writting by MS-DOS, MS-Windows, and MAC. I don't know about other operating systems such as RISC but I suppose it might be true. On MS-DOS/MS-Windows when a file is opened in text mode the '\n' is translated to "\r\n" when written to the file. MAC it is translated to '\r'. So when read back into the program the "\r\n" (or '\r') is transated back to just '\n'.

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

lines 28, 34 and 40. Don't declare val in each of those blocks. Just declare it once at the begining of the function and reuse it everywhere in your program. Its also not necessary to block out those like you did on lines 28 and 32.

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

1) line 36: you don't need that line because line 35 has has already assigned val all the words including spaces .

You can use stringstream to convert from std::string to int or float, but I find it more convenient (in most cases) to just use atol() and atof(). There are problems with using those two functions, but if you KNOW the file contains no errors and the numbers are in normal range then there should be no problems using them. If there are some problems with the values in the file then you should use stringstream so that you can capture errors better.

#include<iostream>
#include <sstream>
using namespace std;

int main()
{
    std::string word = "503,long meadow,12.29";
    int w;
    float z;
    string val;

    stringstream ss(word);
    getline(ss,word,',');
    w = atol(word.c_str());
    cout << w << "\n";
    getline(ss,word,',');
    cout << word << "\n";
    getline(ss,word,',');
    z = (float)atof(word.c_str());
    cout << z << "\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I've been talking to Vicente Fox, the new president of Mexico ... to have gas and oil sent to U.S. so we'll not depend on foreign oil...
--George W. Bush

You mean Mexico isn't part of USA :) It might as well be, with all the illegals crossing the borders.

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

Dear friend thank u tooooooooooooooooooooooooooooooooo much for ur help my application is running after initializing "stInfo"... Thanks for ur help..Many people get good names becoz of helping heart like u...Take care...

Yea, I told you to do that a day ago :) People often waste hours or days because of failure to read and comprehend what they read. That was your problem here.

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

lines 3 and 4: Those should be std::string objects, not char. VB String is something like std::string.

From brief look at that c++ code, you don't know c++ either.

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

Well in VB6 they use Chr()

example:

Do
            sChar = Chr(GetRandomNumber())
        Loop While sChar = Chr(34)

Just wondering if there is a similar function in c++?

Its not necessary to do that in C++ or C. A char can be freely used as either an integer or a character. Both the following are correct (equivalent). while( sChar == 34) or while( sChar == '\"')

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

as previously mentioned, vector class doesn't care how many items you put into it, nor does it care when you do it. You can put an item into the vector at any random times. So when someone logs onto your game, fills out all the information needed for that character class, just add an instance of that class into the vector. The vector class will grow by itself as you add more objects to it.

Mabe what you want is a quick tutorial (click here)

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

>>And How to turnoff the unicode code...
In VC++ 2008 Express -- Project --> Properties -->Configuration Properties-->General
In the right pane, change Character Set to Not Set

See the code I posted -- you did not initialize stInfo structure.

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

I can name all of them, and I'm 15. That's not good :P

Great Going!! Its nice to meet someone your age who knows all those old songs. I'll bet you are one in a million people your age who can do that.

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

You are asking for an awfully lot of information -- the job description for each of those could be a page or two.

You might be able to find some (or all) the information by using google, For example this one: http://www.google.com/search?hl=en&q=what+is+an+infrastructure+architect%2C&btnG=Google+Search

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

I downloaded, installed and compiled the first test program from sfml-dev.org. I am almost certain your problem is that you have to copy the dlls from the lib directory to one of the directories in your PATH statement. After I copied them to d:\windows the program worked ok.

I compiled their tutorial for VC++ 2008

#include <windows.h>
#include <SFML/System.hpp>
#include <iostream>

int main()
{
    sf::Clock Clock;
    while (Clock.GetElapsedTime() < 5.f)
    {
        std::cout << Clock.GetElapsedTime() << std::endl;
        sf::Sleep(0.5f);
    }

    return 0;
}
Nick Evan commented: You took a lot of time to help this guy! +6
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I'm sitting here at work and are just checking newssites and playing webgames...
And you get paid for doing that?

mitrmkar commented: I was wondering the same ... +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

works ok for me (VC++ 2008 Express). The only thing I did with configuration was to turn off UNICODE. Otherwise this is just a normal console program.

#include <windows.h>
#include<iostream>
using namespace std;

int main()
{
STARTUPINFO stInfo;
PROCESS_INFORMATION pi;
memset(&stInfo,0,sizeof(stInfo));
stInfo.cb = sizeof(stInfo);

   BOOL b = CreateProcess( NULL , "C:\\windows\\notepad.exe", NULL, NULL, FALSE, 0 , NULL, NULL, &stInfo , &pi);
   if(b)
       cout << "All ok\n";
   else
       cout << "Failed to create process\n";

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

In the program, did you give CreateProcess() the full path to the file? e.g. c:\windows\system32\notepad.exe? If not, then I suspect the problem may be in the environment variables. The system was probably looking for notepad.exe and couldn't find it. You can easly test this by adding the full path, recompile then retest.

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

Post your questions on one of their forums, afterall they are the experts, not us.

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

you can do this: vector<Character> characters; The above will let you add as many Character class objects as you want to the vector.

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

Welcome to DaniWeb. Hope you enjoy your stay here.
As for your question, please post for discussion in the Software Developers Lounge.

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

just use find() then substr() in a loop

size_t pos;
while( (pos = str.find('\\')) != string::npos)
{
    string tmp = str.substr(0,pos) + str.substr(pos+1);
    str = tmp;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Probably because java is a memory hog, it runs slower because its an interpreted language, and C/C++ languages let you get much closer to the hardware than java does.

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

>2) remove sizeof(char) because its value is guarenteed by the C languauge to always be 1.
But what happens when you decide to support wide characters and forget to add it back?

doesn't matter -- sizeof(char) is still 1.

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

You can also do what I did once --
1) unplug and then remove all cabels from the PC
2) open back door
3) toss pc out the door and watch it smash all over the concete patio. Ooooh what satisfaction :)

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

hi, i am doing my MCA & i am new to c & C++ :). I require your guidence to study & learn about C++.

I dont know its my inablility or lack of practice, whats the best way to learn this.........any one your suggestion plz

thanks
regards
shashi

Welcome to DaniWeb. You can start by reading the Read Me threads in the c++ board. They contain lots of help for new programmers.

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

line 150: you need to use pointer operator instead of dot operator because employee is an array of pointers.

Same line (150): That is going to crash your program big time because employy is an array of uninitialized pointers. All those pointers have to be initialized (allocated) before you can use them.

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

Anyone tried (or does now) watch TV on a PC ? I have Dish Network (satallite TV) for my TV but was wondering how to channel it to my PC.

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

Yeeees! I didn't realize that was a link.

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

And I suspect a camara is also a good thing to have :) I suspect you have a pretty good one too, not one of those throw-aways we can buy from Kodak.

jasimp commented: you don't need a camera ;) +7
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No I don't miss 80s at all. I miss the 40s when I was a small child and took naps with my mother every day. I still take those naps, but not with my mother. :)

There's no time like the present. I don't want to relive the past, but look forward to the future.

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

No but you can go into your control panel and always see all of the reputation you've received

I can only see the first 15 reps. When I click on the arrow in the upper right corner of the rep box it blanks out the box and I see nothing, as if it had reached end-of-result-set in the database.

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

using vista home and ie7: I see the same behavior. Sometimes its two or three threads repeated over and over.

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

According to newspaper reports one Italian cheese factory over a two year period has recovered 11000 tons (!) of spoiled cheese and reworked it into their Mozzarella and Gorgonzola cheese, maggots and all! I guess I won't eat any pizza for a while.

Just had two doughnuts and big mug of fresh Columbian coffee to wash this story down.

Link(s) please.

Here is one I found a few minutes ago -- something like this you are talking about?
http://www.dw-world.de/dw/article/0,2144,3462912,00.html

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

this problem i fixed \o/

now... it wont let me declare more variables :S

This is like going to a car repair shop without the car and asking them to fix it.

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

my complete guess is that the program has run out of memory.

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

I think the reason that it didn't wait for you to enter the filename is because of something that was done earlier in the program, such as entering an integer of some sort. You need to post your whole program in order to determine what the problem is. I know for a fact that the problem is not fscanf().

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

hm... there's something (else) wrong
it pass by directly...

printf("Enter a file name\n"); // here i suppose to type the filename
fgets(filename, sizeof(filename), stdin);

printf("...");

it prints like this...

Enter a file name
...

If you want to print the file name on the last line then do this: printf("%s\n", filename);

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

char *filename[255]

That declares an array of 255 POINTERS, not characters, because of the asterisk (star). Remove the star and it will work ok for you tool.

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

Congratulations, you've singled out the least important part of the style guide.

Not so, tabs are the most visible. They can destroy the whole program no matter how well-written it is. Tabs look crappy when use in code tags here at DaniWeb because they can render the code almost unreadable.

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

I mi$$ the past more than anyone here knows!!

Quality was MUCH BETTER,life was much simpler.........

I love using my Commodore 64very much!!

Too much garbage in todays world........

You are obviously the minority -- Bill Gates didn't become the richest man in the world because of MS-DOS 6.X and earlier operating systems. People wanted complex but pretty operating systems and paid him handsomely for it.

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

hm... there's something (else) wrong
it pass by directly...

printf("Enter a file name\n"); // here i suppose to type the filename
fgets(filename, sizeof(filename), stdin);

printf("...");

it prints like this...

Enter a file name
...

It prints like that because that's exactly what you told it to do. Garbage in, garbage out.

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

there is a max number of variables that i can declare?!
no, right?!

Well yes there is a max, but that was not what I meant. File path including file name can not exceed 255 characters. *nix is similar, but not sure what the max is.

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

don't use scanf() because it won't let you put spaces in the file name.

char filename[255]; // max possible length on MS-Windows
printf("Enter a file name\n");
fgets(filename, sizeof(filename), stdin);
// truncate the '\n' if it exists
if( filename[strlen(filename)-1] == '\n')
  filename[strlen(filename)-1] = 0;
file = fopen(filename, "a");
Salem commented: Yes indeed +18
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't go to see fireworks any more -- watch them mosquito-free on tv. Last night I watched Boston Pops Orchestra annual televised concert, which included nice fireworks afterwords.

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

>>but that is not guaranteed
Yes I know, which is why I made the qualified statement. Only some compilers do that.

getcwd() only gets the current working directory, which is also available in MS-Windows. If the program changes directories before calling getcwd() itt will not give you what you are looking for, assuming you want the path to the *.exe file.

I don't know if there is a POSIX equivalent to GetModueFileName(), but getcwd() is not it.

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

line 107: remove the stars if (p[j]>p[j+1]){ >>I think maybe I want to keep the pointer array to sort???
you don't need pointers.

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

line 13: >>char *ns=(char*)malloc(l*sizeof(char));

1) remove the typecast because C doesn't require the return value of malloc() to be typecast.

2) remove sizeof(char) because its value is guarenteed by the C languauge to always be 1.

line 14 needs to be moved down below line 16. If ns is NULL then you don't want to call strcpy().

So that function might wind up looking like this:

char* m_strdup(char *o){                  // the m_strdup function.......
  char *ns= malloc(strlen(o)+1);
  if(ns != NULL)
       strcpy(ns,o);
  return ns;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

p is an array of 100 pointers. On line 101 you are attempting to assign a double to each array element. If that's what you want, then change the array on line 97 to an array of 100 doubles instead of an array of pointers (just remove the star). Then you also have to remove the star on line 102. line 99: variable temp needs to be changed from a pointer to just a double.

You are using std::string in the class but failed to include <string> header file at the top of your program.

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

look at argv[0] -- some compilers put the full path in there.