• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

problem adding a simple pointer.

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following simple code in C.

#include <stdio.h>
int main()
{
int x = 7;
printf("x is %d\n",x);
x = 14;
printf("x is %d\n", x);
int *aptr = &x;
}


As soon as I add the line       int *aptr = &x;     I get missing ';' before 'type' when I try to compile. Why would that happen? Everything looks fine and compiles fine except when I add that new line. What I am doing should work.
Iam using Visual Studio Professional 2012

thanks
 
Rancher
Posts: 508
15
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jim

It compiles fine for me when I copy/paste your code into a file and compile using gcc in linux. Are you absolutely sure that what you've posted and what you're compiling are the same?

Cheeers
John
 
Jim Smithe
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes and the code is from the video found here talking about creating pointers.
https://www.youtube.com/watch?v=mw1qsMieK5c
Looks like that guy in youtube video uses something other than Visual studio to.
Its is a direct copy and paste from my project.
Unfortunatly I really need it to work in Visual Studio. All my work is in that
 
Marshal
Posts: 79649
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is a good tutorial
 
Saloon Keeper
Posts: 15705
367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What project type did you create in Visual Studio?
 
Jim Smithe
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I think I got it. I had to create a new project and just do it again. For some reason that worked even though they both look the same. I create a win32 console application.
 
Your mother is a hamster and your father smells of tiny ads!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic