Cant program anything

Started by
28 comments, last by MaulingMonkey 19 years, 6 months ago
Hi guys im new to programming and my friend sent me a compiler called bloodshed-dev-c++ basically for c ++ i guess but when i try to put in words such as main void() it says its wrong and then change it to int(). The main i think is for c though then when i get the program to compile it opens it real fast then closes the window i even tried adding a enter (so the comp waits for me to press enter) like %s but it didnt work and still turned off and few erros also occured. here this is what i wrote for a simple program can you tell me if its right or wrong with a c ++ (this doesnt have a escape variable and jus closes) #include <stdio.h> int main() { printf("GoodBye, Cruel World!\n"); } ~thank you for reading~
Advertisement
Your cod eis right the only problem is that it opens the console window only long enough to do all its porcesses.
To fix this add system("PAUSE"); after the printf statment.
______________________________________________________________________________________With the flesh of a cow.
i remember when this happened to me

#include <stdio.h>
#include <windows.h>

int main()
{
print("...");
system("pause");
return 0;
}

edit: betten by 12 sec
One other thing if you are programming in c++ and not c then you should do this:

#include <cstdio>

instead of this;

#include <stdio>

another thing is that the c++ version of printf (not that it matters what you use) is:
cout<<"text goes here";
______________________________________________________________________________________With the flesh of a cow.
what does the include window.h thing do? and can i program c stuff into a c++ compiler or do i need a c compilier ? and whats the diffrence from the stdio thing? Becuase i got that upper program from the c for dummies book from teh begining and it didnt work and didnt ask for a pause series i was wondering why it is so diffrent :(
c++ is backword compadible with c

and i dont know anyother way to use system() but there might be
O and what does the return 0 thing do? i was wondering maybe i gotta start reading more lol but o well thx for this help guys :)
return 0;
returns a error code of 0(no error) to the os
so if c++ is a backward thing to c programs then that means c variables and c keys will work in the c++ compiliers cuz in my eyes it seems that it doesnt :/ and should i put the insert windows.h now for now on ? also what if i suppose i wanted to add a scanf sequence whhat should i do>>?
i got another problem my friend jus gave me a c compilier and stuff but it says this error can you tell me what it means

C:\Documents and Settings\Administrator\Desktop\C
Projects\WHORU.c: line 7: Parse Error, expecting `SEP'
'char me[20] printf("What is your name?")'
aborting compile

from this source

#include <stdio.h>

void main()
{
char me[20;

printf("What is your name?");
scanf("%s",&me);
printf("Darn glad to meet you, %s!\n",me);
}

also when i answer the first question it closes the window once agaain. :(
and it doesnt show the dark glad to meet you part

This topic is closed to new replies.

Advertisement