Tellalca 19 Posting Whiz in Training

If you do not modify and read a data from memory or hard disk, then you don't need to worry about thread safety, I think. The race condition or concurrent access/modify is important when you have a shared data between threads, in this function you do not have. You are doing only computation.

If you need to modify and access a shared data concurrently with multiple threads then you need a lock mechanism. This feature comes out of the box with thread safe modules or you can implement it on your own. You can search the internet.

Tellalca 19 Posting Whiz in Training

If you need help you should write readable sentences.

Tellalca 19 Posting Whiz in Training

First versions of Linux kernel was developed by a lone man called Linus.

almostbob commented: ** AWESOME ** +0
Tellalca 19 Posting Whiz in Training

Don't worry. It is %99.99 guarantee that no body will copy your html codes if you are asking how to prevent it.

almostbob commented: humor +1 +13
Tellalca 19 Posting Whiz in Training

Scripting is programming too, even when you set your watch's alarm you are actually programming.

But generally scripting means writing some commands run line by line, not compiled.

Programming generally means writing some heavy weight code that is compiled into machine code.

Tellalca 19 Posting Whiz in Training

I don't think you should look for a network book special for game development. You can use any good network book to learn basic and then do some socket programming.

I don't have much experience in network programming but that is how I will do this summer.

There is a good socket programming book free online which is referenced by many academic staff too : http://beej.us/guide/bgnet/

nssltd commented: I Agree +3
Tellalca 19 Posting Whiz in Training

You can't erase some data from the file. You must copy the updated data(text in this case) to a new file. You can get the data to the memory then close the file then open the same file with "write" attribute. This deletes all the data in the file. Then flush the updated data to the file. Then you are done.

Tellalca 19 Posting Whiz in Training

It's very hard to read your code since you have no indentation there and also we do not know even what your problem is.

How can you want us to fix your problem if you don't tell the problem ?

Tellalca 19 Posting Whiz in Training

You may try adding up to lets say 100 and then divide all the values by 100 and assign them to the variables. Like;

a=25 b=30 c=40 d=5 adds up to 100.

var1=25/100
var2=30/100
....

If you get stuck post here again.

Kolay gelsin =)

Tellalca 19 Posting Whiz in Training

You can assign the value returned by the function "strlen(textStr)" so you avoid calling this function strlen*26 times :)

int a = strlen(textStr);
 for(j = 0; j < a; j++) {
...
}

Maybe you should use binary files instead. This will decrease the encoding and decoding of the string that will be placed into the buffer, reducing the time your program consume dramatically.

Tellalca 19 Posting Whiz in Training

You should avoid using float values in conditions.

The problem with your code is "scanf("%d", &n );". You are getting input in the form of integer so you are ignoring the fraction part of the input.

You should use "scanf("%f", &n);" to get a floating number.

Tellalca 19 Posting Whiz in Training

Maybe it will be better to declare pi, radius and area as double or float.

If you want to calculate areas of more circles, you can try a loop and then add the areas to the sum.

Tellalca 19 Posting Whiz in Training

I cannot assign my rawWord value to the string array. The program reads a value from testText.txt and then edits it. Then this manipulated char rawWord[20]'s value must be assigned to the string array word. When i debug i see that rawWord is edited correctly, but when it comes to addWord(), the program does not assign the value to the string word[] array. Can you help me with this problem please.

This is my first post, so if i have mistakes sorry.


#ifndef WORDS_H
#define WORDS_H

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

class words
{
	
	int arraySize;
	string word[1000];
	char rawWord[20];
	
	public:
	words(int arraySizeI=1 ): arraySize(arraySizeI){}

	void readWord(fstream & txtPointer)// member function that just reads the data and hold it in the rawWord[]
	{
		txtPointer>>rawWord;
	}
	
	bool checkWord()
	{
		if( !((rawWord[0]>64 && rawWord[0]<91) || (rawWord[0]>96 && rawWord[0]<123)) )// check if it is a word starting with
			return 0;																  // an alphabet
		else // if it is a acceptable formed word then enter this
		{
			return 1;
		}
	}

	void editWord()
	{
		for(int i=0; i<20; i++)
		{
			if( !((rawWord[i]>64 && rawWord[i]<91) || (rawWord[i]>96 && rawWord[i]<123)))
			{
				rawWord[i]=0;
				break;
			}
			else if( (rawWord[i]>64 && rawWord[i]<91) )
				rawWord[i]+=32;
		}
	}
	bool checkSame()
	{
		bool same=0;
		for(int i=0; i<arraySize; i++)
		{
			if( word[i]== rawWord)
			{
				same=1;
				return same;
			}
		}
		return same;
	}

	void addWord()
	{
		word[arraySize-1]=rawWord;
		arraySize++;
	}
};

#endif
#include "200611004_lab2.h"

int main()
{
	bool status;// holds 1 if word is acceptable else …
tux4life commented: Well done on the code tags, for your first post. +8