WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I'll bet its your while (!file.eof()) statement. See this ( .eof() is the same as feof()

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
while (fgets(temp, sizeof(temp), f) != NULL)
	{
		fscanf(f, "%s", &check);
		if (check != "\n")
		{
			newline++;
		}
	}

First of all, newline is a very bad name for a counter. Maybe numLines would make more sense.
Use fgets() instead of fscanf() to read strings.
And isn't check a character array? All you are comparing is the address of check with the address of the constant string "\n". They will never be equal.
What are you trying to accomplish with this test?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I have a file name fun.c contain the fuction to add two number (addnum(a,b)).Now I create another file name callfunc.c.Here I want to call the function (addnum(a,b)) from the file fun.c. How can I do that?.

Create a header file fun.h with a prototype of the function.
Add #include "fun.h" to the beginning of callfunc.c
Compile the two C files together.

Do you realize that in English, when you end a sentence with a . you're supposed to add a space or two so it's easy to understand what you write? That goes for !?, too.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And format your code. It's very difficult to follow.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Well what can we say? Our crystal balls must be on the fritz. You might have to help us see your problem...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Add the program to the Start=>Programs=>Startup list. It will start when the user logs in.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You actually did it in reverse.

int main()
{
    char *namen;
   char test[255] = "Test";

    namen = test;
    cout << test << endl;
    cout << namen << endl;

    return 0;
}

The pointer can receive the address of the array. Not the other way around.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

How is students defined? Isn't it a string? And what string can possibly have the value 0? It might be "0", but never 0.

Does names.resize() take a string (students) as a parameter?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Use 2 indexes, 1 for 'student', 1 for 'new position'. Start them both at 0.
Increment both indices until you find the student you want to remove.
Increment only the student index.
Now continue to the end of the array copying the values in the 'student' index into the positions of the 'new position' index.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Get a degree.

In the 60's and 70's it was easier to get a job without one. But today, why would you hire some self-taught person rather than someone that has a formal education?
Would you buy a house built by the guy's brother-in-law executive that likes woodworking or one built by the guys with training and knowledge?

Yes it costs money, but the benefits in the career are abundant.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Because 1% of the posts that resurrect an old thread might actually have some useful information -- not for the OP but for someone just dropping in.

80% cause problems by
1) Hijacking the post
2) Posting bad code requiring people to correct it
3) Posting wrong code requiring people to besmirch/correct it
4) Uselessly reiterating what was said before
5) Stating an option that is not usable
6) Starting arguments
7) Infracting new members

The other 19% are worthless and sometimes are just ignored, except by those that have to point out the resurrector is a dummy.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

First warning: disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. You don't care that VC doesn't like strcpy so turn the error off.

Next error: look on line 21 and before for the missing ';'

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

okay,here is my source code,I've remade it.the errors are:line 26)no match for operator == in students ==0.
line 28)no matching for function call to std::vector<std::basic string....
lines 36,51,59,68)j not declared in this scope.

I dont know what to do(

I don't see any students==0 anywhere around line 28. And there is no line 59, 68.

When I said "tell us the exact line the error points to" you have to tell us using the line numbers in the post.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

We've added CODE Tags for the last time for you. You already have 4 infractions and 1 warning for not using them. 1 more infraction and you will be banned. This constitutes your last warning.

Follow the rules.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

>>What if during the population of the o's you overwrite an x?

I assumed that possibility was covered by this statement in the original post:

>>a maximum of 5 x's and 100 o's.

which I interpretted to mean there could be 3 x's to start or 95 o's to start, but no more than 5 or 100 respectively. I didn't interpret that to mean there will be exactly 5 x's and exactly 100 o's.

You may assume that, but the program doesn't.
You will always get 100 o's but anywhere from 0 to 5 x's.

If you want 1-5 x's, you should choose a random value and place that many x's.
Then, if you then want 80-100, choose your random value and place that many o's but make sure you don't overwrite your x's

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And it's not dependent on the operating system. It depends on the compiler.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Use C++ string, they are better, and more stable.

C-strings have been around a lot longer than the C++ string class -- therefore they are quite stable...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

To return a string you have to pass it into the function as a pointer. The return statement cannot return a string.

Your for statement at the end will never exit. And what are you calculating in iResult?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

It still does not work,maybe my function definition for two dimensional vector is not right?

Maybe you sould post the exact error message and tell us the exact line the error points to. That way we don't have to guess.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

First thing I'd do is simplify. These two statements llint diff = labs (start < end ? start - end : (start == end ? 1 : end - start)), *genList = calloc (diff, sizeof (llint)); *(genList + i) = i * byWhat * (diff > 0 ? 1 : 0 - 1) + start; are a convoluted mess. Break them into smaller statements so you can see what's really happening. Then if something doesn't work you can display individual components of the equation and see what's going on.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Most everything works fine, except when I type Brent [ENTER] #, I get 6 other characters instead of just 5, one for each letter of Brent. I believe it might have something to do with the [ENTER] but I am not sure. Anyone have any ideas?

That's exactly what your 'problem' is.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I would guess the file did not open properly.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

So what is it doing instead?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Did you actually zero out your counters?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Do not hijack threads with your own questions...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Ok, so did you look up what ^ does. Ok, maybe you should start there.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

This code will not do what you want:

//Populates the grid with x's
            for(int i=0;i<5;i++)
            {
                lifeBoard[rand()%19][rand()%19] = 'x';
            }
            //Populates the grid with o's
            for(int i=0;i<100;i++)
            {
                lifeBoard[rand()%19][rand()%19] = 'o';
            }

What if during the population of the o's you overwrite an x?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i understand what you mean ...

You obviously do not understand..

my problem already in this code

Yes, your problem is in the code. We do understand that.

so for this reason i mentioned the text problem then i set the code of that question ,

You mentioned, but did not explain the problem you are having. All you said is that there is a problem. Without knowing what the problem is, we cannot find a solution.

and that code have errors

Such as? Again, what errors do you have? Tell us!!!

i actually dont know how to solve these errors ,

Without knowing what the errors are, neither do we.

so what i ask is read my question text then my code ,,

We did. You explained nothing.

to help me solve my problem,,,,,

Tell us what the problem actually is.

here the text then the code i had been written ...

Without knowing what we are looking for, why bother reposting the code?

Give us DETAILS.

And use CODE Tags!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Looks to me it's just garbage in the name string after the \0. Before inputting the name you can zero or SPACE out the string.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Something tells me Dell doesn't need to spam. The poster was trying to help, you bozos. :icon_wink:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

if there's a thread that needs bumping, it's this one.

Keep Hope Alive!

NOTE: a 10 day bump.

Nick, you know i love you, man

:P

[EDITED]

nevermind. lets not go there. daniweb is a such a nice site.

and yet you bumped an 11-day dead thread to say that.

now see, this is why we can't have nice things. :icon_frown:

Talking about useless bump posts... I see 10 days is OK but 11 is not.

Yes, I did it too, but I did it once to illustrate a point... :icon_wink:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Duplicate post. Thread closed.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The program needs to read a file, in which position are mentioned in form of 0 and 1, and location (i,j), of the robot, who has to go the end point has to, generate numbers, randomly, BUT ALSO STORE THOSE LOCATIONS SO THAT THE ROBOT DON'T GOES TO THE SAME LOCATION.

Don't yell! We can hear you.

Not a clue what any of this means. So you have a file with 1 & 0. OK, fine.

There are some errors in the program, which I am not able to figure out, and I am not able to store the position that the robot already took, and thus for example, computer generates(2,4), the computer generates the same number again and again, which shoudn't be happening.

There are errors you can't figure out? Neither can we. Not many of us are psychics nor human compilers. You need to give us details, not keep them secret.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Additional:
Just copy the characters into the character array, adding \0 as the last character.

Remember, in C as 'string' is simply an array of characters ending with \0. It's not a special thing, it's not magic. It's just an array of characters by another name.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

When I try, for example,

strcpy(str,threeDays[0][0])

I get an error saying "invalid conversion from 'const char' to 'const char*'; initializing argument 2 of `char* strcpy(char*, const char*)' "... :(

That's because it is very wrong. See my other post for a clue.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
for (int n=0; n<=t.length()-1; n++)
    t[n]='*'

Test for SPACE before executing the statement so you can skip over it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Close.

void Clock::setClock()
{
       UL h, m, s;
     cout << "please enter time in hours, minutes and seconds with a space inbetween  eg. 23 59 59\n";
     cin  >> h >> m >> s;
     
         h+=h*3600;//hours to seconds
         m+=m*60;//minutes to minutes
         s+=s+h+m;//seconds for hours, minutes and minutes
         secs = s % 86400;//using modulus so second contains the remainder less than a full day

If you enter 2 for h, your statement loads h with 7202, not 7200. += is wrong in this case.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Only if each and every line is exactly the the same length. If they aren't, you have no way of knowing where any line starts.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

...understood

I think so.
you want us to write it for you, and you can't be bothered to read the Member Rules. Both are mistakes on your part.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

threeDays[0][0] = 'M'
threeDays[0][1] = 'o'
threeDays[0][2] = 'n'
threeDays[1][0] = 'T'
threeDays[2][0] = 'W'

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I have never posted to a forum before. I am taking a beginning C++ prgmming class.

It shows. You didn't bother to read the Member Rules and made a bad post...

Start by formatting your code so you can follow it. This error is almost always because of misplaced braces and formatting shows very quickly where the error is. It also makes code readable for others (like us) that didn't write it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Every time you use an input statement, you should be checking the return status. Therefore, you should have no problem unless your input file is hosed.

What's the difference between while(infile.good()) and while(!infile.eof()) ? Aren't they (in this context) the same test?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Do you know how to calculate the GCD of a value? That's the code that goes into you CALC button.

If you are asking how to interface with the form, textboxes, and buttons from the beginning, you need a tutorial, not a forum. We help people solve problems, we are not teachers.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

No it's not portable at all. That's why it's not recommended.

C/C++ does not have a standard way to accept input without a Return.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What do you think setw() does given how you used it? What is displayed and what did you expect it to display?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

EOF means end of file. You can check for it like this:

while(!infile.eof())

You could, but it's not recommended unless you are verrrrrry careful. Here's why.

(feof() and .eof() operate identically)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

It creates a leak...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Do not use fflush(stdin) . Here's why.

Reading the meaning, you are only reading 8 characters. Isn't the meaning longer?

And you did not explain well enough what the problem is. What is the result of the code?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Are you absolutely sure the file opens correctly? You need to test the return value of the file open to make sure it's really open.

Can you guarantee that there are exactly 8 values in the file? What if there are only 7? Or 10? You should probably loop, reading 1 number at a time while watching for EOF, and adding the numbers to an array instead of individual values.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Then
1) the batch file is not in the directory specified
2) the system call is not being executed
3) the batch file is being executed and give no feedback
4) the program is not working fine

Maybe more details are necessary.