472,354 Members | 1,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

another weird unexplained anomaly!



Fixed font - Proportional font
string initilization WHY?
All 2 messages in topic - view as tree
puzzlecracker Jan 29, 10:47 pm show options

Newsgroups: comp.lang.c
From: "puzzlecracker" <ironsel2...@gmail.com> - Find messages by this
author
Date: 29 Jan 2005 22:47:59 -0800
Local: Sat, Jan 29 2005 10:47 pm
Subject: string initilization WHY?
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

Why would this work? - and it does! any thoughts?
#include<iostream>

using namespace std;
void init(char **str){ *str="Awesome"; }
main(){

char * str;

init(&str);
cout<<str<<endl;
}

Jul 23 '05 #1
2 1115
puzzlecracker wrote:


Fixed font - Proportional font
string initilization WHY?
All 2 messages in topic - view as tree
puzzlecracker Jan 29, 10:47 pm show options

Newsgroups: comp.lang.c
From: "puzzlecracker" <ironsel2...@gmail.com> - Find messages by this
author
Date: 29 Jan 2005 22:47:59 -0800
Local: Sat, Jan 29 2005 10:47 pm
Subject: string initilization WHY?
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

Why would this work? - and it does! any thoughts?
#include<iostream>

using namespace std;
void init(char **str){ *str="Awesome"; }
main(){

char * str;

init(&str);
cout<<str<<endl;
}


Well, technically it shouldn't work because main() is not a valid prototype
for main. It should be 'int main()'. But that is beside the point here.

Other than that, what is the problem? It is equivalent to

int main()
{
char* str;

str = "Awesome";
cout << str << endl;
}

Why wouldn't it work?

Ian

Jul 23 '05 #2
"puzzlecracker" <ir*********@gmail.com> writes:

Why would this work? - and it does! any thoughts?

I think it would help us reply constructively if you could explain what's so
weird, unexplained or anomalous about the pieces of code you're posting, so
that we could focus our comments accordingly. Is it the "main()" that you
find so weird? What sort of "thoughts" do you want?

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

82
by: nobody | last post by:
Howdy, Mike! mikecoxlinux@yahoo.com (Mike Cox) wrote in message news:<3d6111f1.0402271647.c20aea3@posting.google.com>... > I'm a C++ programmer, and have to use lisp because I want to use >...
1
by: Zaidan | last post by:
I am running Excel2000 under WIN98 2nd edition, and I am writing a VBA code (I will consider using javascript if I have to) that does the following, at the user command: 1- Start MS Explorer and...
6
by: geronimo_me | last post by:
Hi, I'm trying to compare two TITLE fields from different tables to locate anomolies - however Table1 TITLE field contains a dot(.) after some of the entries, however i want to remove the dot so...
188
by: christopher diggins | last post by:
I have posted a C# critique at http://www.heron-language.com/c-sharp-critique.html. To summarize I bring up the following issues : - unsafe code - attributes - garbage collection -...
1
by: John | last post by:
Hi, I have an asp.net page with some validation. On one machine the button click event works fine, whilst on another the button click event does not fire at all Any suggestions welcome! Thanks...
8
by: walesboy | last post by:
greetings - I have a btnSubmit button with a Handles btnSubmit.click which works great if all the user does is click that button. But, if the user ALSO changes a text box on the page (which...
17
by: Barret Bonden | last post by:
As an old programmer just now looking at VB.net I have a question: How does one simply open one form from another ? I don't mean how does one create a new instance of that form , but rather how...
16
by: clintonG | last post by:
At design-time the application just decides to go boom claiming it can't find a dll. This occurs sporadically. Doing a simple edit in the HTML for example and then viewing the application has...
1
by: mai | last post by:
Hi everyone, i'm trying to exhibit FIFO anomaly(page replacement algorithm),, I searched over 2000 random strings but i couldnt find any anomaly,, am i I doing it right?,, Please help,,,The...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.