4 Replies - 912 Views - Last Post: 07 October 2012 - 02:39 AM Rate Topic: -----

#1 cjayaranon   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 06-October 12

a project that simulates an Online Journal

Posted 06 October 2012 - 10:04 PM

good day programmers.. i have been on this project lately. i am trying to make a simulation of an Online Journal.
in the first part is the Main Menu. after it is the sub-menu if you choose 'A'..
on that sub-menu i have trouble accessing my structured data type struct clients. what do i have to do?

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>

struct clients{
	   char fName[15];
	   char uName[10];
	   char pWord[10];
	   int dJoined[10];
	   int dEntry[10];
	   int tEntry[8];
	   char journal[];
int main(){
	printf("MAIN MENU\n[A] New User\n[B] Old User\n[C] Quit\n\n");
	ch = getche();
	ch = toupper(ch);
	FILE *cfPtr;
		 											printf("File could not be opened\n");
				 printf("\nEnter the Full Name\nUser Name\nPassword\nDate Joined.\nEnter EOF to end input.\n");
				 scanf("%s%s%s%d", clients.fName, clients.uName, clients.pWord, clients.dJoined);
				 					 fprintf(cfPtr, "%s* %s* %s* %d*\n", fName, uName, pWord, dJoined);
				 					 scanf("%s%s%s%d", &fName, &uName, &pWord, dJoined);

i also got this error messages..
 G:\proj.cpp expected primary-expression before '.' token

Is This A Good Question/Topic? 0
  • +

Replies To: a project that simulates an Online Journal

#2 snoopy11   User is offline

  • Engineering ● Software
  • member icon

Reputation: 1460
  • View blog
  • Posts: 4,726
  • Joined: 20-March 10

Re: a project that simulates an Online Journal

Posted 06 October 2012 - 10:16 PM


You have a struct called clients so in main you have to instantiate a new instance of the struct

like this

clients newclient;

then you can access it by

newclient.fName etc..

You have other errors...

Was This Post Helpful? 1
  • +
  • -

#3 jdavi134   User is offline

  • D.I.C Head

Reputation: 42
  • View blog
  • Posts: 225
  • Joined: 26-October 11

Re: a project that simulates an Online Journal

Posted 06 October 2012 - 10:26 PM

Snoopy said that perfectly.

But for future reference. Formatting your code to be easily read by anyone trying to read it can come in handy. I hate to say it but this code looks like a jumbled mess and is one of my biggest pet peeves.

Just a quick tip. Line up corresponding: curly braces, statements/expressions that might take up more than one line, method headers, etc.. If you want a quick simple example, try this link below. It will give you a short 10-12 line code piece that is well formatted and universally easy to read.


Happy Coding =)
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6166
  • View blog
  • Posts: 21,264
  • Joined: 05-May 12

Re: a project that simulates an Online Journal

Posted 06 October 2012 - 10:44 PM

As an aside, you seem to be saving your code into .cpp file indicating that you want write C++ code, yet the code you have posted seems to be primarily C code with the use of printf(), fopen(), etc.
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: a project that simulates an Online Journal

Posted 07 October 2012 - 02:39 AM


Nope, doesn't work the way you think.

char journal[];

Again, wrong. you have to give an array a size at the time of declaration.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1