Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Visual C++ and C programming

Visual C++ and C programming

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studiotutorialquestion
30 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B BadKarma

    hi, try to change **main()** to **void main()** codito ergo sum

    T Offline
    T Offline
    thierrypp
    wrote on last edited by
    #21

    again error: C:\Documents and Settings\atvd\Desktop\New Folder00ppp\wwww\wwww.cpp(72) : error C2440: '=' : cannot convert from 'void *' to 'struct etudiant *' Conversion from 'void*' to pointer to non-'void' requires an explicit cast Error executing cl.exe. wwww.exe - 1 error(s), 0 warning(s)

    1 Reply Last reply
    0
    • T thierrypp

      yes, but there an error message: Compiling... ooooo.cpp c:\documents and settings\atvd\desktop\new folder00ppp\ooooo\ooooo.cpp(161) : fatal error C1010: unexpected end of file while looking for precompiled header directive Error executing cl.exe. ooooo.exe - 1 error(s), 0 warning(s) and when clicking on the error message , it shows the end, after the last } maybe I should ad a main...? how...? Thanks a lot!

      B Offline
      B Offline
      BadKarma
      wrote on last edited by
      #22

      The default compiler options needs a pre compiled header. You should add #include "stdafx.h" to the begining of your code. Another solution is to remove this option from your compile directive. Its been a long time since I used VC++6.0 but I think this is what you should do. 1. open project properties from menu or press Alt+F7 2. select the file ooooo.cpp in the tree view 3. select compile options in the right form. 4. select pre compiled header from the combo box 5. set the radio button to disable the use of pre-compiled headers. codito ergo sum

      T 1 Reply Last reply
      0
      • B BadKarma

        The default compiler options needs a pre compiled header. You should add #include "stdafx.h" to the begining of your code. Another solution is to remove this option from your compile directive. Its been a long time since I used VC++6.0 but I think this is what you should do. 1. open project properties from menu or press Alt+F7 2. select the file ooooo.cpp in the tree view 3. select compile options in the right form. 4. select pre compiled header from the combo box 5. set the radio button to disable the use of pre-compiled headers. codito ergo sum

        T Offline
        T Offline
        thierrypp
        wrote on last edited by
        #23

        same problem..... C:\Documents and Settings\atvd\Desktop\New Folder00ppp\uuuu\uuuu.cpp(31) : warning C4508: 'main' : function should return a value; 'void' return type assumed

        1 Reply Last reply
        0
        • T thierrypp

          yes, files with a c extension *.c for example: and result of compilation.. for example: /* ---------- */ /* premier2.c */ /* ---------- */ #include #include main() { int nb, diviseur1, diviseur2,reste ; int trouve,i ,racinecar,limite ; int nb_iterations=1; printf("Entrez un Nombre :"); scanf("%d",&nb); /* partie entiere de la racine carre+1 */ limite=sqrt(nb)+1; trouve=0 ; if (nb != 2) /* 2 est premier */ { /* on retire le cas des nombres pairs */ reste=nb%2 ; if (reste == 0) { trouve=1 ; /* on memorise les diviseurs */ diviseur1=2 ; diviseur2=nb/2 ; } else { /* teste tous les diviseurs impairs */ i=3; while ( (! trouve) && (i<=limite) ) { nb_iterations++; reste= nb%i ; if (reste == 0) { trouve=1 ; /* on memorise les diviseurs */ diviseur1=i ; diviseur2=nb/i ; } i+=2 ; } } } if (trouve) { printf("%d n'est pas premier !\n",nb); printf("il est divisible par %d et %d\n",diviseur1,diviseur2); } else { printf("%d est un nombre PREMIER !\n",nb); } printf("RŽsultat obtenu en %d itŽrations\n",nb_iterations); } result: Linking... LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/premier2.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. premier2.exe - 2 error(s), 0 warning(s)

          G Offline
          G Offline
          Graham Bradshaw
          wrote on last edited by
          #24

          Does this article[^] help at all?

          T 2 Replies Last reply
          0
          • G Graham Bradshaw

            Does this article[^] help at all?

            T Offline
            T Offline
            thierrypp
            wrote on last edited by
            #25

            thank you...but I turned it and tested it.....same ..errors listen, I do not want to abuse too much... my mail is thierrypp@yahoo.com if you want, I will send you a typical set of files and you could send me screenshots? I would be very grateful if you could. I am working on Visual C++ 6.0 with standard edition provided with Ivor Horton book, and indeed I made a lot of successful applications with VC++ 6.0. But with C.....I followed before your link and after and the problems remains...what a pity! Thanks a lot! The big problem is that the company left for several months nobody in charge of managing this and after restructuration, no notes, nothing....only me to deal with... Best regards and thanks, Thierry

            1 Reply Last reply
            0
            • G Graham Bradshaw

              Does this article[^] help at all?

              T Offline
              T Offline
              thierrypp
              wrote on last edited by
              #26

              a typical example, no *.h files /* ---------------------- */ /* structure_en_globale.c */ /* ---------------------- */ #include #include /* -- declaration des constantes -- */ #define TAILLE_NOM 20 #define TAILLE_PRENOM 2*TAILLE_NOM #define MAX_ETUDIANTS 50 struct etudiant { char nom[TAILLE_NOM] ; char prenom[TAILLE_PRENOM] ; int age ; } ; /* -- variables globales -- */ int nbeleves=0 ; struct etudiant tab_eleves[MAX_ETUDIANTS]; /* -- procedures et fonctions -- */ void saisie_eleves(); void affichage() ; struct etudiant recherche_eleve(char nom_recherche[]); /* ----------------------------------- */ main() { struct etudiant eleve ; char nom_eleve[TAILLE_NOM] ; int choix = -1 ; /* -- boucle d'affichage du menu -- */ while (choix != 0 ) { printf("\n"); printf(" -1- Saisie d'une liste d'Žlves \n"); printf(" -2- Recherche d'un Žlve \n"); printf(" -3- Affichage de la liste\n"); printf(" -0- FIN\n"); printf("\n"); printf("Choix:"); scanf("%d",&choix); /* -- selecteur : appel des procedures -- */ switch (choix) { case 1 : saisie_eleves(); break ; case 2 : printf("Entrez le nom de l'Žlve :"); scanf ("%s",nom_eleve); eleve=recherche_eleve(nom_eleve); if (! strcmp(eleve.nom,"NON_TROUVE")) { printf("Aucun %s trouvŽ\n",nom_eleve); } else { printf("Nom : %s\n",eleve.nom); printf("PrŽnom : %s\n",eleve.prenom); printf("Age : %d\n",eleve.age); } break ; case 3 : affichage(); break ; case 0 : printf("Au revoir \n"); break ; default: printf("Erreur de saisie\n"); break; } } } /* ----------------------------------- */ void saisie_eleves() { struct etudiant studtmp ; int termine ; termine = 0 ; /* -- boucle de saisie du tableau des eleves -- */ while (! termine) { printf("Entrez un nom (\"fin\" pour terminer):"); scanf("%s",studtmp.nom); termine=((strcmp(studtmp.nom,"fin"))==0) ; if (! termine) { printf("Entrez un prŽnom:"); scanf("%s",s

              1 Reply Last reply
              0
              • T thierrypp

                Hi, God Morning/afternoon, May I know how to work with c files on a visual C++ 6.0 IDE? Some people say it is easy, howver I am encountering a lot of problems. examples simple. project. the c file looks like: /* ------------- */ /* mon_include.c */ /* ------------- */ #include main() { #include "mon_include.h" i = 10 ; j = 20 ; k = i+j ; printf("k = %d\n",k); } and the *.h file /* ------------- */ /* mon_include.h */ /* ------------- */ int i,j ; int k ; /* ------------- */ Thanks a lot, I work on Visual C++ 6.0 introductory edition. T.

                R Offline
                R Offline
                Rage
                wrote on last edited by
                #27

                thierrypp wrote:

                May I know how to work with c files on a visual C++ 6.0 IDE?

                Two possibilities: 1. You want to keep the project as a c-project, then you need to change the calling convention in your project settings. 2. You do not care about it being c or c++, then simply rename your .c files .cpp and everything will be ok. Hope this helps ~RaGE();

                T 1 Reply Last reply
                0
                • R Rage

                  thierrypp wrote:

                  May I know how to work with c files on a visual C++ 6.0 IDE?

                  Two possibilities: 1. You want to keep the project as a c-project, then you need to change the calling convention in your project settings. 2. You do not care about it being c or c++, then simply rename your .c files .cpp and everything will be ok. Hope this helps ~RaGE();

                  T Offline
                  T Offline
                  thierrypp
                  wrote on last edited by
                  #28

                  thanks for the informations but in fact, the problem remains...... Maybe if someone knows about Lcc-win 32? Regards T.

                  S 2 Replies Last reply
                  0
                  • T thierrypp

                    thanks for the informations but in fact, the problem remains...... Maybe if someone knows about Lcc-win 32? Regards T.

                    S Offline
                    S Offline
                    Shraddhan
                    wrote on last edited by
                    #29

                    Thierry, I approached this in a methodical way. Follow me and you should be OK: In Visual C++ 6.0 create a new project. Choose Win 32 Console Application, select a simple application. Delete the lines: int main(int argc, char* argv[]) { return 0; } Copy the code in. I used one of the examples you supplied. Compile: get 5 errors, 1 warning. Looking at what the errors were, I deleted the following two lines which are clearly wrong: #include #include The other three errors are about printf, scanf, strcmp not being recognised. I guess that I need to include some files. I moved the cursor on to the word printf and hit the F1 key. Visual C++ 6.0 gave some information on how to use this function. It also said that it needed the include file . Same for scanf. For strcmp, Visual C++ 6.0 says that I need to include . So I added the next two lines. #include #include Now there is a warning: warning C4508: 'main' : function should return a value; 'void' return type assumed Being just a warning, I could have ignored this. But to do the job properly, as I have been told that main() should return a value, I changed the line main() to be: int main() and to return a value, I added the following line just before the end of the main() function: return 0; Et voila! It compiles. And runs. No problemo, as they say. (And by the way, the source file that Visual C++ created is indeed .CPP, not .C) Shraddhan

                    1 Reply Last reply
                    0
                    • T thierrypp

                      thanks for the informations but in fact, the problem remains...... Maybe if someone knows about Lcc-win 32? Regards T.

                      S Offline
                      S Offline
                      Shraddhan
                      wrote on last edited by
                      #30

                      Oops! The bit biter swallowed some of my text. Yhe files to be included are stdio.h and string.h I guess that because these names were included inside angle brackets they got chopped off. That is preumably the reason why they were missing from the code sample you supplied. Bon chance, Shraddhan

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups