Author Topic: Ds Dude's Programming Corner :D  (Read 4263 times)

0 Members and 1 Guest are viewing this topic.

Offline ds dude

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 631
  • Lolicon Forever.
Re: Ds Dude's Programming Corner :D
« Reply #20 on: March 26, 2009, 09:09:06 am »
About a word counting program, here's how I would do it (and did it in a pascal script thing).

Make the count start at 1.
Find first character in the string that is a space. Add 1 to count. Then cut the string up to that point, cutting out the space. Repeat until there are no more spaces.

Alright, I'll see what I can do with my program, thanks. :)

Also, I'm as of right now downloading Ubuntu. I'll dual boot with my laptop.

EDIT: It appears that I have made a big mistake. I would like inform you guys that saving the file type "C Source File" does not keep it as C, it still keeps it as C++ (Note: if you look at the soufce file logo it says C++). You have to also change the file to end with ".c."

For example: "myapplication.c." So I believe that is what has caused trouble with me in the past, I will make note to change all file types.

I am now done with Word Counting, I'm moving on with Arrays. Here is some code.

Code: [Select]
#include <stdio.h>

/* count digits, white space, others */
main()
{
int c, i, nwhite, nother;
int ndigit[10];

nwhite = nother = 0
for (i = 0; i < 10; ++i)
ndigit[1] = 0;

while ((c = getchar()) != EOF)
if (c >= '0' && c <= '9')
++ndigit[c-'0'];
else if (c == ' ' || c == '\n' || c == '\t')
++nwhite;
else
++nother;

printf('digits =");
for (i = 0; i < 10; ++i)
printf(" %d', ndigit[i]);
printf(", white space = %d, other = %d\n",
nwhite, nother);
}
« Last Edit: March 26, 2009, 12:10:48 pm by ds dude »
This signature was borked. Now it is not.

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: Ds Dude's Programming Corner :D
« Reply #21 on: March 26, 2009, 12:37:09 pm »
The c/c++ thing shouldn't be a problem if the program compiled correcty. If it wouldn't work the compiler would bug you and you'd never be able to make an .exe ... I think anyway :p

Although your switching to Linux:
I forgot to mention that command prompt will exit as soon as the .bat file is finished, sorry about that. I'm pretty sure there's a setting for that, but you could also change the .bat file to:
Code: [Select]
:REPEAT
bladibla.exe
GOTO REPEAT
This will keep the window open until you tell it to exit or start over again. Anyway all this antique methods won't be your problem when using Linux anymore :)
Come join: EliteCTF
Listen to: My Music

Offline ds dude

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 631
  • Lolicon Forever.
Re: Ds Dude's Programming Corner :D
« Reply #22 on: March 26, 2009, 01:25:22 pm »
The c/c++ thing shouldn't be a problem if the program compiled correcty. If it wouldn't work the compiler would bug you and you'd never be able to make an .exe ... I think anyway :p

Although your switching to Linux:
I forgot to mention that command prompt will exit as soon as the .bat file is finished, sorry about that. I'm pretty sure there's a setting for that, but you could also change the .bat file to:
Code: [Select]
:REPEAT
bladibla.exe
GOTO REPEAT
This will keep the window open until you tell it to exit or start over again. Anyway all this antique methods won't be your problem when using Linux anymore :)

Alright, sounds good. I have to burn it on a disk for safe keeping.

I'll try to reconfigure the .bat file, thanks. I'll post back or edit this post and see if it works.

EDIT: It works, but I get an error saying that Word counting.exe is not an operable batch file or program.

I'll rename the executable without spaces in the name, I heard that it sometimes causes a problem.

EDIT2: I was correct! That was the problem, it works. The example.txt has to be in the same folder with text in it, right?
« Last Edit: March 26, 2009, 01:47:25 pm by ds dude »
This signature was borked. Now it is not.

Offline Xxypher

  • Veteran
  • *****
  • Posts: 1319
  • Soldat Veteran.
Re: Ds Dude's Programming Corner :D
« Reply #23 on: March 26, 2009, 04:57:36 pm »
xxypher that is in GML am i correct?
Yep, GML.

Offline ds dude

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 631
  • Lolicon Forever.
Re: Ds Dude's Programming Corner :D
« Reply #24 on: March 29, 2009, 08:48:15 am »
I am still currently working on Array functioning, might take a day or two to sort out. I will post the results within a week.

I will be leaving for a week, the upcoming Monday, hopefully this topic doesn't get old fast. :-X
This signature was borked. Now it is not.

Offline Xxypher

  • Veteran
  • *****
  • Posts: 1319
  • Soldat Veteran.
Re: Ds Dude's Programming Corner :D
« Reply #25 on: March 30, 2009, 11:21:22 am »
Using Game Maker is one of the BEST ways to make a game. Why? Because you can use C++ an GML.
GM8 will have built in C++, so goodbye DLL's!

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Ds Dude's Programming Corner :D
« Reply #26 on: March 30, 2009, 04:55:49 pm »
Using Game Maker is one of the BEST ways to make a game. Why? Because you can use C++ an GML.
GM8 will have built in C++, so goodbye DLL's!
OR you can program it from scratch which makes you feel all warm and fuzzy on the inside when it works right.

Offline Xxypher

  • Veteran
  • *****
  • Posts: 1319
  • Soldat Veteran.
Re: Ds Dude's Programming Corner :D
« Reply #27 on: March 31, 2009, 10:02:33 pm »
Programming in Game Maker the way I do is programming from scratch. All I am handed is the codes to begin with.